This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 1357
    
  17
Hi,

Have you tried using



or the
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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: 2491
    
    8


would give you

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Eliminates Duplicates in List
 
Similar Threads
4 Problems Interacting Simultaneously
newbie needs help
Problem with 2 collection
Native query always returning same data
DAOs and complex/aggregated objects