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