Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jpa-dev] Path navigation join semantics

Hello,

I would like to discuss 4.4.4. Path Expressions, specifically this section:

> Path expression navigability is composed using “inner join” semantics. That is, if the value of a nonterminal field in the path expression is null, the path is considered to have no value, and does not participate in the determination of the result.

What is the reason behind requiring "inner join" semantics? From the examples I have seen so far in the specification, they would also work if a JPA provider would use "left join" semantics because all examples use such paths in the WHERE clause and since NULL OP ANYTHING is always UNKNOWN in SQL, the effects on cardinality are mostly the same with "left join" semantics when used in a predicate context i.e. the WHERE, HAVING or ON clauses or CASE predicate etc.

I'm asking this because it IMO makes not much sense to require "inner join" semantics, especially for the SELECT, ORDER BY and GROUP BY clauses but also in predicate context for null aware predicates/functions.


I would like to be able to use the implicit navigation like this:

SELECT NEW my.company.MyDto(e.id, e.name, e.parent.name) FROM Entity e

but due to the current semantics this will currently filter out entities that have no parent due to "inner join" semantics, so I have to write the following instead:

SELECT NEW my.company.MyDto(e.id, e.name, p.name) FROM Entity e LEFT JOIN e.parent p


I would like to propose changing the specification to require left join semantics there and also for `Path.get` as specified in 6.5.5. for JPA Criteria API. This will simplify a lot of queries and aligns with what entity graphs do semantically.

Ideas? Comments?


Regards,

Christian



Back to the top