I'm using Hibernate 3.6, and I have a class Shop with a field alternateCodes of type Set<String>, that is mapped as follows:
<set cascade="all-delete-orphan" lazy="true" name="alternateCodes"
table="shops_alternateCodes">
<key column="SHOP_ID" not-null="true"/>
<element column="CODE" length="32" not-null="true" type="string"
unique="true"/>
</set>
and I would like to build a Criteria that would search a Shop that as an alternateCodes that contains some string.
The HQL equivalent would be something like this:
from Shop s join s.alternateCodes c where c=?
How can I express this using the criteria API?
Thanks in advance
P.S.
I have tried this:
teria = getPm().createCriteria(Shop.class);
...
teria.createAlias("alternateCodes", "acode");
teria.add(Restrictions.eq("acode", code));
but of course, it doesn't work.