• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eliminates Duplicates in List

 
safraz hanas
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Geeks,

Im developing an application using core java MySQL 5.0 & Hibernate 3.2.1. I'm expecting a solution for the following problem

I'm having 2 tables,
1. job, which is master table
2. jobSequence which is detail table

relationship is one-2-many (job to jobSequence)

table data :

JOB
+--------+----------+
| job_id | sequence |
+--------+----------+
| 1 | 152 |
| 2 | 256 |
| 3 | 306 |
+--------+----------+

jobSequence

+-----------+--------+
| JOBSEQ_ID | JOB_ID |
+-----------+--------+
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| 4 | 2 |
+-----------+--------+


when i use the following query,

List jobs =
ses.createQuery(" from ImJobs as job " +
"left join fetch job.imJobSequence as imJobSequence where job.jobId = imJobSequence.imJobs.jobId ").list();

I get

+--------+-----------+
| JOB_ID | JOBSEQ_ID |
+--------+-----------+
| 1 | 1 |
| 1 | 2 |
| 2 | 3 |
| 2 | 4 |
+--------+-----------+

My Problem

How can i get the corresponding job sequences from job?

Your assistance is highly appreciated...

Is this infomation sufficient?

Thanks in advance.
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Have you tried using



or the
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't a Java question, it's a SQL question. I'm moving this to our JDBC forum.

Note that an opener like "Hi Geeks" generally won't win you many friends.
 
Jan Cumps
Bartender
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

would give you

Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic