Hi,
Suppose I have 3 tables:
Table A
---- id
---- Name
Table B
---- id
---- Name
Table AB
---- id
---- PK of A
---- PK of B
AB table is a link table between A and B (A and B PKs are FKs in AB).
I'm trying to use the Criteria API to get A objects from the AB link table. Is that possible? Suppose I want all A objects whose name attribute is equal to "xxx" and are associated with the B object whose id is 10?
What I managed to do is to get all AB objects that satisfy these conditions:
Code:
Criteria crit = session.createCriteria(AB.class);
crit.createCriteria("A", "a");
crit.createCriteria("B", "b");
crit.add(Restrictions.eq("a.name","xxx");
crit.add(Restrictions.eq("b.id", 10);
But what I really need is to get all A objects. What should I do?
Thanks in advance!