Hi,
I am working with the Criteria API. The most queries have not been any problem, but for one query, I do not find a solution. There are two tables: Sight and Attendance. Between the two tables, there is a n:m relation. Now I want to get all sights that offer certain attendances. If there is an other attendance to look for, which the sight does not offer, the sight has not to be shown.
Here es an example.
Sight: 1, Pont du Gard Attendance: 1, German speaking personal 2, near a station 3, handicapped accessible 4, free parking
Pont du Gard offers the attendances 2 and 3.
Now I want to see all sights which offers the attendances 2, 3 and 4. Pont du Gard must not to be shown, because it offers only two of the three attendances. If Pont du Gard would offer all attendances, then it is shown because it offers the attendances I look for and one more.
I tried an in Restriction, but it does not work properly: criteria.createCriteria("attendanceList").add(Restrictions.in("attendanceId", filter.getAttendanceIds()));
With the example above, it shows Pont du Gard, although it offers only two attendances.
Does anyone know a possibility to write such a query?
I hope you understand, what I mean.
With kind regards,
Christopher
|