Hibernate version: 3
Hello, everyone. I've got a generic, but not necessarily simple, HQL question.
I have a database of bibliography citations. Each citation has a list of associated keywords. Keyword and Citation are both mapped objects, with a many-to-many relationship. Each object maintains a collection of references. I.e., Citation has a list of Kewords, and Keyword has a list of Citations.
One of the requirements of the search functionality for this app is to be able to search for citations by keyword, but I'm having some trouble figuring out how to write an HQL query for a citation that contains one or more of a list of keywords. In native SQL, I would be pulling the list of citation ids from the citation-keyword join table something like this:
Code:
SELECT citationID
FROM citation_keywords
WHERE keywordID IN ( <keyword ID list goes here> );
I'm still trying to get my head completely around HQL, though. I know I can reference the keywords collection on the Citation object like this:
Code:
from Citations cite
where 1450 IN elements(cite.keywords.id)
But what do I do since I'm looking for one
or more keywords in that collection?
Thanks in advance for all your help!
-- Kintar