休眠到许多反向查询

时间:2016-01-18 08:13:26

标签: hibernate hql hibernate-onetomany

我有2个实体BankruptcyAttorneyNameQuestion之间有很多关系,其中有{2}在Answer问题中定义。

如果不在Answer' and no one2many defined in实体中添加one2many关系,我如何使用hibernate查询没有任何答案的问题?

类似的东西:

Question

1 个答案:

答案 0 :(得分:1)

这样的事情:

select q from Question q
where q not in (select a.question from Answer a)

顺便说一句,你提供的查询是“太多SQL”,请记住,尽管它们的语法相似,但SQL和JPQL在概念上是不同的。