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: SOLVED Need query help
PostPosted: Wed Oct 06, 2010 2:47 am 
Newbie

Joined: Wed Oct 07, 2009 7:34 am
Posts: 12
Hi, I Have two entities with relations:

House and persons
House have many person, I Need to bring a list of houses, fetching persons, but I want to bring only persons under 12.

@OneToMany(mappedBy = "house", cascade = CascadeType.REMOVE)
private Set<Person> persons;

Example
house 1 have 3 persons: 45, 17,7
House 2 have 4 persons: 55,56,8,3.

Yhe result i want Is:

house1 with a set of size 1 (person 17)
house 2 with a set of size 2 (person 8 and 3)

Is it possible with a HQL clause??


Last edited by wiji on Wed Oct 06, 2010 3:16 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Need query help
PostPosted: Wed Oct 06, 2010 2:57 am 
Newbie

Joined: Wed Oct 07, 2009 7:34 am
Posts: 12
SOLVED:

"SELECT DISTINCT house FROM House house
LEFT JOIN FETCH house.Persons per
WHERE per.age <= 12"


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.