HQL with Null检查一对一关系 [英] HQL with Null check for one-to-one relation
本文介绍了HQL with Null检查一对一关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Hibernate中我有以下一对一关系(可能为null):
< one- to-one name =detailsclass =com.example.Detailslazy =falsecascade =all/>
我试图选择所有具有HQL的非空细节的实体:
$来自实体e的b$ b
,其中e.details不为空
,但是这会返回所有实体,无论细节是否为null。
那么正确的HQL会是什么?
好的我找到解决方案: 从实体中选择e加入e.details d其中d不为空
I have the following one-to-one relation in Hibernate (that could be null):
<one-to-one name="details" class="com.example.Details" lazy="false" cascade="all"/>
I am trying to select all entities that have non-null details with HQL:
from Entity e where e.details is not null
but this returns all entities, no matter whether details are null or not.
What would be a correct HQL then?
解决方案
Ok I found the solution:
select e from Entity e join e.details d where d is not null
这篇关于HQL with Null检查一对一关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文