Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Conditional LEFT JOIN in JPQL

It is not exactly clear to me what you are trying to return from the query. (JPQL will not accept a.*. You'll need to be specific about what you want back.

You should be able to do something like this:

select distinct a, b, c
from EntityA a left join a.b b, left join a.c c
where .....

JPQL does not give the option of doing joins in the WHERE clause, so a relationship is required.

You can do native SQL, or use EclipseLink native API do do more complex queries.


vide wrote:

  I have two questions about JOIN's in JPQL:
1. Is it possible to write a conditional LEFT JOIN with JPQL, which in SQL
looks like:

SELECT a.*, b.*, c.*
  FROM entityA a
  LEFT JOIN entityB b ON AND b.some_field="some_value"
  LEFT JOIN entityC c ON AND c.some_field="some_value"
  WHERE some_other_post_conditions

2. Can I use LEFT JOIN's in JPQL on entities, which don't have relationship
annotations between each other?


Back to the top