Using Left Joins in HQL on 3 Tables

后端 未结 2 1625
鱼传尺愫
鱼传尺愫 2021-02-05 16:17

I have three tables A B and C. Now i want to execute this sql query in HQL:

select * from A as a 
left join 
B as b 
on 
a.id = b.id 
left join 
C as c 
on 
b.t         


        
2条回答
  •  悲&欢浪女
    2021-02-05 16:28

    I suppose you've already defined all the needed associations in your configuration. If so, in HQL it would look like this:

    from A as a left join a.B as b left join b.C as c 
    

    There is no "ON" statement in HQL, hibernate does automatically based on your mappings and defined Associations.

    Pay attention to a.B and b.C.

    You refer to B and C based on already defined aliases a & c.

提交回复
热议问题