Reputation: 10689
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'
Upvotes: 13
Views: 21204
Reputation: 61
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
Upvotes: 0
Reputation: 10689
This is possible with JPA with following query:
FROM A as a, B as b WHERE b.col1=a.col1 OR b.col1 IS NULL
Upvotes: -5
Reputation: 19002
You cannot do that in JPA, as long as there is no relationship between the entities.
Solutions:
Upvotes: 10