This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes Eliminates Duplicates in List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Eliminates Duplicates in List" Watch "Eliminates Duplicates in List" New topic
Author

Eliminates Duplicates in List

safraz hanas
Greenhorn

Joined: Feb 21, 2007
Posts: 10
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

Joined: Nov 03, 2006
Posts: 1347
    
  13
Hi,

Have you tried using



or the
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

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.


[Jess in Action][AskingGoodQuestions]
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2477
    
    7


would give you

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eliminates Duplicates in List
 
Similar Threads
4 Problems Interacting Simultaneously
Problem with 2 collection
newbie needs help
DAOs and complex/aggregated objects
Native query always returning same data