[hibernate-dev] Why does implicit join translate to inner join?
mihalcea.vlad at gmail.com
Thu Feb 22 07:19:36 EST 2018
Maybe Steve remembers the reason why INNER JOIN was chosen.
One possible reason was to have a single way of treating implicit joins.
In WHERE and ORDER BY clauses, implicit join makes sense to render an INNER
Only when used in the SELECT clause only, LEFT JOIN would work just fine.
So, I guess it was because we wanted to handle the implicit join in the
same fashion no matter where it is used.
But, I might be wrong, so I'm looking forward to Steve's answer too.
On Thu, Feb 22, 2018 at 12:05 PM, Lukas Eder <lukas.eder at gmail.com> wrote:
> Sure, there may be a chicken and egg situation between Hibernate and JPA,
> but I'm trying to understand why this was specified the way it is, as I
> find this quite surprising.
> 2018-02-22 10:59 GMT+01:00 andrea boriero <andrea at hibernate.org>:
> > Hi Lukas,
> > I think it is based on JPA 2.1 spec, 4.4.4 Path Expressions , "Path
> > expression navigability is composed using “inner join” semantics."
> > On 22 February 2018 at 08:09, Lukas Eder <lukas.eder at gmail.com> wrote:
> >> Hello,
> >> Vlad Mihalcea  was so kind to point me to this mailing list with my
> >> question about implicit joins. The user guide  states that:
> >> "Implicit joins are always treated as inner joins."
> >> To me, this seems wrong, semantically, if implicit joins follow optional
> >> (nullable) foreign key relationships. Let's assume that customers have
> >> optional addresses. When we write
> >> SELECT c.firstName, c.lastName, c.address.city.country.code
> >> FROM customer c
> >> The resulting query will INNER JOIN the customer / address / city /
> >> country
> >> tables, filtering out customers with no address, or addresses with no
> >> cities, or cities with no countries (let's ignore the modelling aspect).
> >> In
> >> fact, I got a CROSS JOIN with join predicate in the WHERE clause, but
> >> doesn't really change anything. Hence the SELECT clause applies a
> >> which is rather surprising. To me, this seems simply wrong just like it
> >> would be wrong for Stream.map() to apply any filters.
> >> However, I'm sure there must have been good reasons to default to this
> >> behaviour, even in the presence of optional foreign keys.
> >> Does anyone know what those reasons are?
> >> Cheers,
> >> Lukas
> >> : https://twitter.com/vlad_mihalcea/status/965927462684196864
> >> : http://docs.jboss.org/hibernate/orm/5.2/userguide/
> >> html_single/Hibernate_User_Guide.html#hql-implicit-join
> >> _______________________________________________
> >> hibernate-dev mailing list
> >> hibernate-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/hibernate-dev
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
More information about the hibernate-dev