Search code examples
javasqljpaopenjpa

OpenJPA Left Outer Join conditions


Is it possible to translate the following to (Open)JPA?

select t0.*
from Person t0
left outer join Car t1
on t0.id = t1.id_person
and t1.type = 'blah'

What I want is to specify outer join conditions. Note that the query is different from the following:

select t0.*
from Person t0
left outer join Car t1
on t0.id = t1.id_person
where t1.type = 'blah'

In the first query, it returns empty data for the cases where the Car is not of type 'blah'. In the last query, it doesn't return Person rows if the car is not of type 'blah'.


Solution

  • I could not find any information on this, so I assumed it doesn't. I ended up creating a view and querying the view instead.

    By the way, hibernate allows this through the with keyword.