JPA - left join 2 tables without association

Viewed 16885

I have 2 tables/entities with no association. I can go for cross joins in JPA

FROM A as a, B as b WHERE b.col1=a.col1

How Can I perform a left-join?

I want all values from A and fill them up with B values where possible and leave NULL where there is no B.

Does not work:

FROM A as a LEFT JOIN B as b WHERE b.col1=a.col1

Path expected for join!

Invalid path: 'b.col1'

4 Answers

Regarding Dimitri Dewaele's answer, this query is a CARTESIAN JOIN. The CARTESIAN JOIN or CROSS JOIN returns the Cartesian product of the sets of records from two or more joined tables. Thus, it equates to an inner join where the join-condition always evaluates to either True or where the join-condition is absent from the statement. If you want to read more about it, follow the link below: Sql Cartesian Joins

Apparently you can now do this as of Hibernate 5.1

Related