views:

34

answers:

0

I am trying to assemble a query using hibernate criteria.

In my db, there is a [Game] table, a [Tag] table, and a many-to-many relationship modelled using a join table called [GameTag], which contains a game_id field and a tag_id field.

My input is a list of tags (or tag_ids), and I would like to retrieve all games having all of these tags.

[example]
game 1 has tag1, tag2 and tag3
game 2 has tag2 and tag3
game 3 has tag3

My input is [tag2, tag3].

My output should be game 1 and game 2, as these both have the two tags specified.