We're updating the issue view to help you get more done. 

HQL different behavior with fetch

Description

In a postgres database I have:
A User attached with a profile.
This profile does not have authorities.

And this HQL request:
@Query("from User u " +
"inner join fetch u.profile " +
"left join fetch u.profile.authorities " +
"where u.id = ?1")

With Hibernate 4.3.11:
u.profile.authorites throw a 'org.hibernate.LazyLoadingException'.

With Hibernate 4.3.10
u.profile.authorites is empty which is fine.

If there are authorities linked to this profile everything is fine.
The problem seems to appear only when there is nothing to fetch.

This can be fixed with the following request:
@Query("from User u " +
"inner join fetch u.profile p " + //create an alias
"left join fetch p.authorities " + // alias used here
"where u.id = ?1")

I am wondering if the first request I do is supposed to be valid or if there is an issue in the new version 4.3.11.
Thank you very much for your help.

Environment

postgres, spring boot 1.2.7. Hibernate 4.3.11

Status

Assignee

Gail Badner

Reporter

Clément Tamisier

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

4.3.11

Priority

Major