How to perform left join in Hibernate Query Language?

后端 未结 1 694
清歌不尽
清歌不尽 2021-01-12 13:18

This is my HQL query, but it isn\'t working and is throwing an error.

Hql query:

SELECT 
    *
FROM 
    TABLEA A 
LEFT JOIN 
    A.TABLEB B 
WHERE 
         


        
相关标签:
1条回答
  • 2021-01-12 13:54

    In HQL you can use LEFT JOIN only with linked property in main entity:

    Sample

    EntityA has an object entityB of type EntityB so you can

    SELECT A FROM EntityA A LEFT JOIN A.entityB B WHERE ...
    

    IF EntityA haven't entityB property but is EntityB have a property entityA, you can't write this:

    SELECT A FROM EntityA LEFT JOIN EntityB B WHERE B.entityA = A 
    

    because you have an error. This is an Hibernate issue not resolved yet.

    0 讨论(0)
提交回复
热议问题