-->
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.  [ 4 posts ] 
Author Message
 Post subject: HQL query.
PostPosted: Fri May 15, 2009 3:32 am 
Newbie

Joined: Sat Oct 11, 2008 7:28 am
Posts: 10
Location: New Delhi (INDIA)
Hi Friends,

I am not getting how to write a query in hql for following scenario:

I have object person and this object has reference to collection of addresses. Both are stored in different tables.
Now I need to fetch person objects with addresses only of type "addressType='ShippingAddress'". This addressType field is defined in Addresses class.

_________________
Thanks,
Arun


Top
 Profile  
 
 Post subject: Re: HQL query.
PostPosted: Fri May 15, 2009 3:42 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Try something like:
Code:
from Person p join p.adresses a where a.adressType = 'ShippingAdress'

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: HQL query.
PostPosted: Sat May 16, 2009 4:18 am 
Newbie

Joined: Sat Oct 11, 2008 7:28 am
Posts: 10
Location: New Delhi (INDIA)
I tried this one but its not providing the required results.
Actuly the condition "where a.adressType = 'ShippingAdress'" is not working.

_________________
Thanks,
Arun


Top
 Profile  
 
 Post subject: Re: HQL query.
PostPosted: Mon May 18, 2009 5:40 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
What do you mean with not working? What is the result? Any exception?
Do you mean, that the person's collection still contains all addresses, but you want it to have only the filtered ones?

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.