This JPQL query:
select p from Post p where p.status = 'public' or p.author.name = 'John'
Translates to a join
between post
and author
, so it misses all records that are public (status = 'public'
) that has no author (author = null
).
Any way to convert this to a left join, without adding an explicit left join clause to the "from" part?
I can't do an explicit left join on the "from" part like this:
select p from Post p left join p.author a where p.status = 'public' or a.name = 'John'
Because the code that generates the p.author.name = 'John'
clause has no way to add a new relation to the "from" part.
So, this part is static, I can only append clauses to it:
select p from Post p where p.status = 'public'