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: Query question
PostPosted: Thu Mar 26, 2009 7:12 pm 
Newbie

Joined: Thu Mar 26, 2009 6:59 pm
Posts: 1
Hi

I have a domain object Customer that contains a list of CustomerEvent objects in a List named customerEvents. A CustomerEvent has a field called "type"

I would like to query for all Customers that has at least one CustomerEvent that has its type set to a spesific value.

How do I do this in HQL? I've scanned the documentatjon, but I don't seem to find the correct query? Do I have to use a an explicit join, or are there shortcuts? How should I write the query?

Br,
Anders


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 27, 2009 3:00 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Something like the following HQL should work:

Code:
select distinct c from Customer c join c.customerEvents ce where ce.type = :type


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.