-->
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: many-to-many query issue
PostPosted: Mon Oct 20, 2003 3:33 pm 
Regular
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,


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.