[hibernate-dev] Why does implicit join translate to inner join?

andrea boriero andrea at hibernate.org
Thu Feb 22 04:59:45 EST 2018

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 [1] was so kind to point me to this mailing list with my
> question about implicit joins. The user guide [2] 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 that
> doesn't really change anything. Hence the SELECT clause applies a filter,
> 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
> [1]: https://twitter.com/vlad_mihalcea/status/965927462684196864
> [2]: 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

More information about the hibernate-dev mailing list