小编典典

具有Null检查的HQL一对一关系

hibernate

我在Hibernate中具有以下一对一关系(可能为null):

<one-to-one name="details" class="com.example.Details" lazy="false" cascade="all"/>

我正在尝试使用HQL选择所有具有非空详细信息的实体:

from Entity e where e.details is not null

但这会返回所有实体,无论详细信息是否为空。

那么正确的HQL是什么?


阅读 401

收藏
2020-06-20

共1个答案

小编典典

好的,我找到了解决方案:

select e from Entity e join e.details d where d is not null
2020-06-20