jpa - When is an explicit JOIN required in JPQL? -
consider following jpa 2.0-compliant jpql queries:
select p postaladdress p join p.constituent c c.id = :constituentid order p.type.displayorder ...and:
select p postaladdress p join p.constituent c join p.type t c.id = :constituentid order t.displayorder in both cases, p.type @manytoone relationship entity (postaladdresstype).
the difference in 2 queries in first 1 there no explicit join postaladdress postaladdresstype. implied, guess, through p.type.displayorder snippet in where clause. in second, there explicit join.
are these queries equivalent?
are equivalent to:
select p postaladdress p p.constituent.id = :constituentid order p.type.displayorder ...?
it seems so. in these cases, explicit joins (between postaladdress , constituent, , between postaladdress , postaladdresstype) in way (other readability , explicitness)?
for completeness, understand join required if path expression evaluates collection; i'm not (at moment :-)) interested in case.
it's required each time want left join , not inner join.
Comments
Post a Comment