且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HQL留下了不相关实体的连接

更新时间:2023-02-09 21:20:30

目前,使用HQL的where子句中加入不相关类的t​​heta样式仅支持内部连接。

Currently, the theta-style on joining the unrelated classes in the where clause using HQL only supports inner join.

请求为了支持这种情况的外连接,目前是第3次投票最多的增强,但我不认为这个功能将在近端功能中实现,因为它需要重新实现当前基于ANTLER的查询解析器,这似乎是一项巨大的IMO任务。

The request for supporting the outer join for such situation is currently the 3-rd most voted enhancement but I don't think this feature will be implemented in the near feature as it requires the re-implementation of the current ANTLER-based query parser first which seems to be a gigantic task IMO.

如果您坚持使用HQL执行左连接而不添加A和B之间的关系,则可以使用选项3首先执行内连接,然后使用follow ng HQL

If you insist to use the HQL to perform left join without adding the relationship between A and B , you can use option 3 to do the inner join first, then use the following HQL

from A a where a.some not in ( select b.some from B)

查找所有无法加入B并以编程方式结合结果的A。

to find out all the A that cannot join B and combine the results programmatically .

自版本5.1.0开始 HHH-16(Explicit joins on unrelated classes) is fixed,we should be能够加入不相关的实体。

As of release 5.1.0 HHH-16 (Explicit joins on unrelated classes) is fixed and we should be able to join the unrelated entities.