Hibernate标准因连接表而异

时间:2013-01-18 21:53:13

标签: mysql hibernate distinct

我有一个表A,其中有一个表B的外键字段。 我想获取(Criteria API首选,HQL OK)X条目 A 具有唯一B引用,

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

FROM A AS a
WHERE a.b IN (SELECT ax.b 
              FROM A AS ax 
              GROUP BY b HAVING COUNT(b) = 1)