-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Understanding results of a join (newbie question)
PostPosted: Thu Aug 05, 2010 3:27 pm 
Newbie

Joined: Thu Aug 05, 2010 3:20 pm
Posts: 6
I have a Parent class with a one-to-many relationship with Child. The member variable in Parent looks like:

Code:
@OneToMany
@JoinColumn(name="parent_id")
private List<Child> child;


The HQL looks like:

Code:
from Parent p join fetch p.child c


Say I have two parent records, the first with three children and the second with two. I expect the above HQL to return a List of Parent with size = 2. Instead it returns a List of Parent with size = 5, as the first Parent object is repeated three times (I guess once for each child) and the second Parent object is repeated twice.

Is this the result I should expect? I want a list with just one entry each for each Parent object.


Top
 Profile  
 
 Post subject: Re: Understanding results of a join (newbie question)
PostPosted: Fri Aug 06, 2010 10:23 am 
Newbie

Joined: Thu Aug 05, 2010 3:20 pm
Posts: 6
Surely someone can answer this question?

I've read the documentation and browsed multiple tutorials, however they do not provide the answer I'm looking for. Somebody?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.