如何根据第 4 个 table 属性作为连接条件在休眠中添加左连接多个 table

How to add left join multiple tables in hibernate based on 4th table attributes as join condition

我有 4 张桌子

A,B,C,D

我想执行以下 SQL 查询:

select *
from A
  left join B
    on a.d = b.d
  left Join C
    on c.d = b.d

请建议我如何实现它我在 A/B/C 中为 D

映射
@Override
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ID", nullable = false)
public D getDObj() {
   return DObj;
}

求推荐。

已更新

我已经根据您的配置做了一些测试,这是对我有用的 HQL 查询:

select distinct a 
from A a, B b, C c 
where ((a.d=b.d) or (a.d is null) or (b.d is null)) 
   and ((b.d=c.d) or (b.d is null) or (c.d is null))

它支持 D 的连接并且对 LEFT JOIN 友好。