-->
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.  [ 1 post ] 
Author Message
 Post subject: how to have the same results of a query without subselects
PostPosted: Wed Jun 23, 2004 12:48 am 
Regular
Regular

Joined: Tue Aug 26, 2003 6:59 pm
Posts: 89
Location: Somewhere in the Ghetto
im basically trying to find out if user with id 1 has a role with id 1 in its user.roles set, im using a mysql db without subselect support

i havent tested this only a db with subselects but I think it should work

select r from Role as r where r.id = 1 and r in (select u, elements(u.roles) from User as u where u.id = 1)


<class name="o2.model.User" table="user" proxy="o2.model.User">

<id column="id" name="id" type="long" unsaved-value="-1">
<generator class="increment"/>
</id>

<property name="name" type="string"/>

<set name="roles" lazy="true" table="userrole" cascade="save-update" order-by="roleId">
<!--set name="roles" lazy="true" table="userrole" cascade="save-update"-->
<key column="userId"/>
<many-to-many column="roleId" class="o2.model.Role"/>
</set>

</class>

<class name="o2.model.Role" table="role" proxy="o2.model.Role">
<cache usage="read-only"/>

<id column="id" name="id" type="long" unsaved-value="-1">
<generator class="increment"/>
</id>

<property name="name" type="string"/>

<set name="users" lazy="true" table="userrole" inverse="true">
<key column="roleId"/>
<many-to-many column="userId" class="o2.model.User"/>
</set>

</class>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.