-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query elements question
PostPosted: Wed May 05, 2004 5:00 pm 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
Hello,
I am having a problem understanding the best method to find if a user is in a group.

I have a User that contains a many2many List of Sections which contains a one2many List of Categories.

I am trying to create a query that will find all the users that belong to a Category which is the pojo of Categories. I know what the id of the Category is.

I am using the following Query:

Code:
Query query =    mySession.createQuery("from UserBean as user where ? in elements(user.sections.categories)");

query.setParameter(0, categories);

findBeans = (ArrayList) query.list();


My question is, how do I pass id into the query? Because what I have now isn't working. Any help would be great!

---Jason


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 2:22 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
from UserBean as user, Category as cat
where cat in elements(user.sections.categories)
and cat.id = :id


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 9:31 am 
Beginner
Beginner

Joined: Tue Dec 30, 2003 1:51 pm
Posts: 49
Location: Michigan, USA
sweet - thanks. i will give it a try...

regards,

jason


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