does anyone know if and how the solution for following question (which is written in the JPA API) can be written using the hibernate criteria API?
To be more specific I
Late answer.
The correct propertyName for collection (annotated by @ElementCollection) is "elements"
or constant CollectionPropertyNames#COLLECTION_ELEMENTS.
Try with the following answers
Criteria crit = getSession().createCriteria(Discussion.class);
crit.createAlias("participants", "p");
crit.add(Restrictions.eq("p.elements", portalUsername));
or use the constant COLLECTION_ELEMENTS instead
crit.add(Restrictions.eq("p." + CollectionPropertyNames.COLLECTION_ELEMENTS, portalUsername));