class A{
// one to many mapping
List<B> listOfB;
//getter and setter;
class B {
String s;
//getter and setter
}
Now, when I get class A , it will return all the associated class Bs in listOfB. But I need certain condition on which of B should be in response. Like Get A such that listOfB contains all such B for which s = ‘something’.
EDIT : currently this is not working:
select a from A a where a.listOfB IN (select b from a.listOfB b where b.s='something');
1) I assume that you mapped a one-to-many relation from A to B like A.listOfB = B.b
I think your query can be simplified as:
The equivalent Hibernate Criteria query would be:
2) If there is no relation mapped between these entities you can use an SQLRestriction over the field a.listOfB
More examples here.