-->
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 run not in query using Hibernate criterion?
PostPosted: Thu May 20, 2010 1:06 am 
Newbie

Joined: Thu May 20, 2010 12:38 am
Posts: 1
Hi

We have two tables in our application called Groups and Tags. There is many to many relationship between Groups and Tags. For this we have another table GroupTag which has groupId and TagId.

-- Table 1 --
Groups

Id int
GroupName varchar

-- Table 2 --
Tags

Id int
TagName varchar

-- Table 3 --
GroupTag

id int
groupId int
tagId int

A group can have multiple tags and a tag can belong to many groups (although this does not matter, we may not allow tag to be included in many groups at same time).

In this situation how I can find the tags which are not present in the given group.

Lets say i have one Group called Group 1 and Five Tags tag1, tag2, tag3, tag4 and tag5.

I need to execute this query.

select * from tags where id not in (select t.id from tags t
left join GroupTag gt on t.id = gt. tagid
where groupId = '1')

How I can execute in hibernate ?

Please help.


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.