I am new to using Criteria, and i am trying to join tables on my query.
This is my expected query set up
Select * FROM ATable a INNER JOIN BTable b ON a.id = b.f开发者_开发技巧k_id WHERE fk_pname = ":cat";
Do you know how i can add the "INNER JOIN BTable b ON a.id = b.fk_id"?
I already added in instance, but not sure how to add the other table. Criteria criteria = this.getSession().createCriteria(ATable.class);
Thanks again for all your help
Something like this will do it - Criteria criteria = this.getSession().createCriteria(ATable.class) .createAlias("btable","b") .add(Restrictions.eq("b.pname",":cat")
The string 'btable' refers to the property name in the ATable entity class that corresponds to the BTable entity.
精彩评论