Hibernate version: 3.1.1
Hi,
I have been struggling with the following issue for some time, I am hoping that someone can point me in the right direction:
I have an entity (A) which has a one-to-many collection of elements.
To make the problem simple lets say that the collection is just a Set of Strings.
What I want to do is return all A's where the collection contains a particular string, in HQL it is easy to do:
FROM A a WHERE :x in elements(a.bs)
However this is part of a larger query so I am trying to use the Criteria API to build it.
The problem I am having is that I have not been able to find any way to express this query using the Criteria API, specifically:
- The "in" restriction assumes that I will be passing in the RHS of the expression (and I want the left).
- I can't create a DetachedCriteria for the collection, because I have no entity class to use to create it.
- I can create an alias / sub criteria because the collection is of values not entities.
- I can't use the . (dot) notation because the element (string) has no properties I can reference.
Therefore I would greatly appreciate it if someone could point me in the right direction.
TIA
|