8

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 
    A.COLUMNNAME = B.COLUMNAME

and it causes this error:

org.hibernate.QueryException:
This Query caught Exception. could not resolve property: of TABLEB:TABLEA.

How can I solve this problem? Actually I retrieved a value from more than one table. This query doesn't work with CreateQuery(strQuery).

Sled
  • 18,541
  • 27
  • 119
  • 168
karthik.A.M
  • 115
  • 2
  • 2
  • 11

1 Answers1

13

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.

Joe Taras
  • 15,166
  • 7
  • 42
  • 55