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>
|
|