Select an entity according to a list of associated entities

Posted by Maverickch on Stack Overflow See other posts from Stack Overflow or by Maverickch
Published on 2010-04-27T08:50:30Z Indexed on 2010/04/27 8:53 UTC
Read the original article Hit count: 218

Filed under:
|

I have the following database schema :

Two tables, books and tags, with n-m relationship.

Books - Tags

We can have for example the book 1, with tags {A,B,C}, and book 2, with tags {A}.

I would like to select the books according to a list of tags.

For example : selected tags list : {A,B} -> book 1

My idea was to use the MINUS SQL function, to subtract book tags list to the selected tags list, and return the book if the list was empty. Unfortunately, this SQL function is not supported by HQL.

Any idea about that ?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about hql