-->
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: Quering in collections of complex values
PostPosted: Fri Oct 06, 2006 3:57 pm 
Newbie

Joined: Fri Oct 06, 2006 1:54 pm
Posts: 5
Location: Costa Rica
Hi, I have a some tables called Person, Roles and Person_Roles. I have something similar than this:

Code:
<class name="model.Person" table="PERSON">
    <id name="id">
        <generator class="identity" />
    </id>
      ......
    <set table="person_roles" name="roles">
      <key column="person_id"/>
      <many-to-many column="role_id" class="model.Role"/>
    </set>
</class>


I want query something like this:

SELECT p.id, p.name FROM person p , person_roles pr WHERE p.role_id = pr.role_id and pr.role_id in (1,2,3);

I want the person who have 1, 2 or 3 role type.

Its possible do something like the following?:

Code:
from Person p where p.roles.id in (1,2,3) ?


Thanks for any help

_________________
Carpe Diem!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 07, 2006 1:56 am 
Regular
Regular

Joined: Wed Jul 27, 2005 2:33 am
Posts: 118
Try this out:

Code:
from Person p join p.roles r where r.id in (1,2,3)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 1:41 pm 
Newbie

Joined: Mon Dec 31, 2007 1:35 pm
Posts: 1
jaikiran wrote:
Try this out:

Code:
from Person p join p.roles r where r.id in (1,2,3)


Hi,
Is this possible to rewrite this query(or similar to this) using DetachedCriteria? I was trying but i always fail :(


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.