I need to create a Hibernate criteria restriction that ors 3 Conditions. The problem is that the last condition is acutally to conditions using the AND operator.
My fir
A sequence of restrictions linked with or
is called a disjunction. A sequence of restrictions linked with and
is called a conjunction.
So, what you need is
So here it goes:
Criterion startInRange = Restrictions.between("expectedStartCanonicDate", rangeStart, rangeEnd);
Criterion endInRange = Restrictions.between("expectedCompletionCanonicDate", rangeStart, rangeEnd);
Criterion thirdCondition =
Restrictions.conjunction().add(Restrictions.le("expectedStartCanonicDate", rangeStart))
.add(Restrictions.ge("expectedCompletionCanonicDate", rangeEnd));
Criterion completeCondition =
Restrictions.disjunction().add(startInRange)
.add(endInRange)
.add(thirdCondition);
criteria.add(completeCondition);
Criteria criteriaObj = sessionselectreply.createCriteria(TaskReplyVO.class,"taskreply")
.createAlias("taskreply.objTaskView", "taskview")
.createAlias("objMailTo", "mailto")
.add(Restrictions.eq("taskview.longTaskId", taskid))
.add(Restrictions.eq("mailto.longuserid", userid));