-->
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: EJB-QL for testing for existence in a collection?
PostPosted: Wed Jun 21, 2006 12:13 pm 
Newbie

Joined: Mon Sep 05, 2005 10:52 pm
Posts: 6
Hi all,

I'm trying to translate a query from Criteria-based to EJB-QL / HQL based. What I have is an entity named PlotMessage, with an author property, and a jointAuthors List-type collection property.

I need to select all PlotMessages where the author is equal to the author object I pass in, or the author object I pass in is a member of the jointAuthors collection. I'm trying to figure out if this is what the HQL elements() function is useful for.

What I have so far is the following:

select pm from PlotMessage pm where pm.author = :author or :author in elements(pm.jointAuthors)

Is this the appropriate query? Is there something in EJB-QL that doesn't use the elements() function, since it's Hibernate-specific?

Thanks!

--Scott


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 26, 2006 3:47 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
What about just plain IN?

Code:
select pm from PlotMessage pm, Author a where a = :author and (pm.author = a or IN (pm.jointAuthors) a)


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.