我在 Hibernate 中有以下一对一关系(可能为空):
<one-to-one name="details" class="com.example.Details" lazy="false" cascade="all"/>
我正在尝试使用 HQL 选择所有具有非空详细信息的实体:
from Entity e where e.details is not null
但这会返回所有实体,无论 details 是否为 null。
那么什么是正确的 HQL?
最佳答案
好的,我找到了解决方案:
select e from Entity e join e.details d where d is not null
关于java - HQL 与 Null 检查一对一关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7248278/