0
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”吗?

我已经添加了实例,但不确定如何添加另一个表。标准条件 = this.getSession().createCriteria(ATable.class);

再次感谢你的帮助

4

1 回答 1

1

像这样的东西会做到 - Criteria criteria = this.getSession().createCriteria(ATable.class) .createAlias("btable","b") .add(Restrictions.eq("b.pname",":cat" )

字符串'btable'指的是ATable实体类中与BTable实体对应的属性名。

于 2011-05-05T19:04:48.393 回答