-->
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: problems with many to many relation and nested query
PostPosted: Wed Mar 17, 2004 6:41 pm 
Newbie

Joined: Wed Mar 17, 2004 6:30 pm
Posts: 1
I have these two classes defined in hibernate

User{
String username;
List groups;
}

Group{
group_id;
}

"select elements(users.groups) from User as users" works fine, but what I'm trying to do is trying to get all the users in the same group as a certain user. How would i do something like that in HQL. My best guess so far has been "from User as users1 where elements(users1.groups) in (select elements(users.groups) from User as users)". But this doesn't work.

Any help would be greatly apreciated.

regards
Michael


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 19, 2004 6:23 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
from User user join user.groups group where group in (select elements(users.groups) from User as users)

Should work but you'll have to distinct your users

_________________
Emmanuel


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.