I'm wondering if anyone has a new solution to this problem, this thread is a few months old. I'm using Hibernate 3.1.3
I've got a branching domain model where a person is either a Employee or a non-employee and I want to search both groups at once.
Here's my Criteria expression - (although it's part of a very large search switch)
Code:
Criteria crit = session.createCriteria(Person.class);
crit.createCriteria("dutytours", "dt").createAlias("dutyassignments", "da");
crit.createCriteria("nfedutytours", "nfedt").createAlias("nfedutyassignments", "nfeda");
crit.add(
Expression.disjunction()
.add(Expression.conjunction()
.add(Restrictions.isNull("da.enddate"))
.add(Restrictions.in("da.assignmentdutystation",locationArray))
)
.add(Expression.conjunction()
.add(Restrictions.isNull("nfeda.enddate"))
.add(Restrictions.in("nfeda.assignmentdutystation",locationArray))
)
)
The query works fine except for the generated where clasue:
Code:
from PS.PERSON this_
left outer join PS.NONFEMAEMPLOYEE nonfemaemp6_ on this_.PERSONID=nonfemaemp6_.PERSONID
left outer join PS.EMPLOYEE employee7_ on this_.PERSONID=employee7_.PERSONID
inner join PS.DUTYTOUR dt1_ on this_.PERSONID=dt1_.PERSONID
inner join PS.DUTYASSIGNMENT da2_ on dt1_.REQUESTID=da2_.REQUESTID and dt1_.PERSONID=da2_.PERSONID
inner join PS.NFEDUTYTOUR nfedt3_ on this_.PERSONID=nfedt3_.PERSONID
inner join PS.NFEDUTYASSIGNMENT nfeda4_ on nfedt3_.NFEDUTYTOURID=nfeda4_.NFEDUTYTOURID
left outer join ASD_MASTER.VW_ISAAC_PEOPLE vwisaacpeo12_ on this_.PERSONID=vwisaacpeo12_.USER_ID
Any help would be greatly appreciated, I'm about to rewrite it in HQL.