I have already tried it but it didn't work.
If for example the object
STUDENT has 2 records of type
DEGREE, and only if one of them satisfies the
conjunction (school and schoolDepartment) and there is no value
degreeType to satisfy the criterion in any of the 2 rows then I will have a result although it is something that it is wrong.
I want to have a result if
both of these 3 criteria are satisfied, the
school and
schoolDepartment in the same row
AND and the
degreeType in
another row or in the same.
Ananasi wrote:
This should work for you:
Code:
criteria.createCriteria("degrees", "jsdegrees");
Set schoolSet = new HashSet();
schoolSet.add(school);
Set schoolDepSet = new HashSet();
schoolDepSet.add(department);
Set postGradDegreeSet = new HashSet();
postGradDegreeSet.add(postGraduateDegreeType);
criteria.add(
Restrictions.disjunction()
.add(
Restrictions.conjunction()
.add(Restrictions.in("jsdegrees.school", schoolSet))
.add(Restrictions.in("jsdegrees.schoolDepartment", schoolDepSet))
)
.add(Restrictions.in("jsdegrees.degreeType", postGradDegreeSet))
)