-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Query with Criteria API
PostPosted: Thu Sep 22, 2011 2:57 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.