aspose file tools*
The moose likes Object Relational Mapping and the fly likes Parent child join query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Parent child join query" Watch "Parent child join query" New topic
Author

Parent child join query

Raaj Aaryan
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Hi,

I have a parent table and a child table with one-to-many relationship. Each parent record is related to one or more child records.

For example each record in PEOPLE (parent table) has one or more records in PHONE (child tables).

I have an application which generates an XML file from the result object returned from the PEOPLE table. The structure of the output is like



If I run a simple query on the PEOPLE table due to the association with the PHONE table, it runs a series of associated select on the child tables. To avoid this I make use of from the parent table onto the child table. But when I run this query I get duplicated entries for each record which has more than one phone number.

I think I have to make use of tuple queries to remove this duplication in results, but not sure how to do it. Can anyone suggest me the approach to do it.

thanks in advance
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Please post your mapping files, and your code for the query.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Raaj Aaryan
Greenhorn

Joined: Feb 07, 2008
Posts: 4
Here is the mapping file of the parent table


and the query is



I have tried to remove these duplications using a tuple query but I am still curious to solve my earlier problem
 
jQuery in Action, 2nd edition
 
subject: Parent child join query
 
Similar Threads
Single query that counts children including zero elements
So much on the Left Joins in Hibernate
Getting a single entity from a query
Building JSP pages and link to MySQL table
Hibernate performance issues using huge databases