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.fk_id WHERE fk_pname = ":cat";
你知道如何添加“INNER JOIN BTable b ON a.id = b.fk_id”吗?
我已在实例中添加,但不确定如何添加其他表。 Criteria criteria = this.getSession()。createCriteria(ATable.class);
再次感谢您的帮助
答案 0 :(得分:1)
这样的事情会做到 - Criteria criteria = this.getSession()。createCriteria(ATable.class) .createAlias( “BTABLE”, “B”) 。新增(Restrictions.eq( “b.pname”, “:猫”)
字符串'btable'指的是ATable实体类中与BTable实体对应的属性名称。