I have a class User containing a Set of Strings:
Code:
class User
{
private Set theKeywords = new HashSet(); // of String
void setKeywords(Set aSet)
{
theKeywords = aSet;
}
Set getKeywords()
{
return theKeywords;
}
}
The mapping file for the User class looks something like:
Code:
<class name="User" table="USER">
<id name="Id" column="ID" type="long">
<generator class="increment"/>
</id>
<property name="Name" column="NAME" type="string"/>
<set name="Keywords" table="KEYWORDS">
<key column="USER_ID"/>
<element column="VALUE" type="string"/>
</set>
</class>
Now I want to perform a query where I search all users that have a certain keyword. I can't seem to get it to work (not with HQL nor with Criteria objects). Can anyone help me here; the query I would like to execute is something like:
Code:
select u
from User u, ??? k
where k.user_id = u.id
and k.value = 'text'
The problem is that the Keyword is just an ordinary String and not a specific class for which I have defined a custom mapping.
All help is greatly appreciated, Hugo.
PS: I'm using hibernate 2.1.7c.