Regular |
|
Joined: Tue Aug 26, 2003 3:34 pm Posts: 54 Location: Farroupilha - Brasil
|
Hello all,
How could I write this query using HQL ?
select * from nom_privilege p inner join nom_group_privilege gp on p.id<>gp.privilege_id where group_id = 4;
OR
select * from nom_privilege p where not exists (select * from nom_group_privilege gp where gp.privilege_id = p.id and gp.group_id = 4);
Schema:
GROUP <-*------*-> PRIVILEGE
<class name="com.estobel.model.Group" table="nom_group">
.....
<set name="privileges" table="nom_group_privilege" lazy="true"
cascade="none">
<key>
<column name="group_id" not-null="true"/>
</key>
<many-to-many class="com.estobel.model.Privilege">
<column name="privilege_id" not-null="true"/>
</many-to-many>
</set>
</class>
<class name="com.estobel.model.Privilege" table="nom_privilege">
.....
<set name="groups" table="est_group_privilege" inverse="true" lazy="true">
<key>
<column name="privilege_id" not-null="true"/>
</key>
<many-to-many class="com.estobel.model.Group">
<column name="group_id" not-null="true"/>
</many-to-many>
</set>
</class>
Thanks,
|
|