Hello, i have a problem with Criteria Queries.
I have 3 entities: location (1:n) locationteammapping (m:1) team
I want to get all locations with a specific locationname or teamname.
For each returned location i want to get all locationteammappings. But location.getLocationteammappings() only returns the mappings where the teamname is matching.
Example: Loc A - Team X Loc A - Team Y Loc C - Team Z
If i search for "A" the query will return "Loc A". "Loc A".getLocationteammappings() returns X and Y.
If i search for "X" the query will return "Loc A". "Loc A".getLocationteammappings() only returns X. Y is missing.
It seems that the collection is already initialized with the query result. How can i avoid this?
My Query:
Criteria c = getSession().createCriteria(Location.class); c.createAlias("locationteammapping","m", CriteriaSpecification.LEFT_JOIN); c.createAlias("m.team", "t", CriteriaSpecification.LEFT_JOIN);
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); c.setFetchMode("locationteammapping",FetchMode.SELECT);
Disjunction dis = Restrictions.disjunction(); c.add(dis);
dis.add(Restrictions.ilike("locationname", "A", MatchMode.ANYWHERE)) dis.add(Restrictions.ilike("t.teamname", "A", MatchMode.ANYWHERE))
Thanks Andi
|