EntityGraph has limit in depth levels for hibernate 6.1.6.Final (and 6.1.7.Final)

I upgraded my Spring Boot Java application from 2.7.5 to 3.0.2 All works fine except of EntityGraph when the I need to retrieve a very deep property:

report.reportStages.taskLibrary.tasks.team.members.user

this chain worked pretty good with the lower version of hibernate but with the latest one just report.reportStages.taskLibrary.tasks are populated; for team - teamId is provided but team is null.

Please advise how this issue can be solved with the latest version of hibernate ORM.

Thank you in advance.

Please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

Probably the same issue: EntityGraph does not fetch 4-level data after migrating to Hibernate 6

1 Like

We will only know for sure if you test it. Also, try Hibernate ORM 6.2.0.CR4. Chances are, we already fixed your issue.

it’s definitely the same issue.

I already tested it myself. 3 levels of depth working as a charm - no problems at all but if we have more deeper relationships - that’s it - the value will stay null.

If it’s the same issue, you can watch that and will get notified as soon as we have the time to fix it.

I’m adding 1 more issue to this: we were able to get the Pageable sorting data by field like team.members.user.firstName and total elements showed the expected number of elements on the prior version of hibernate. Now I’m getting the filtered result: only records for which this association is filled are provided in the content of Pageable, records with null values are filtered out !

If you are facing a new issue, please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

Note though, that a path expression over associations will always result in inner joins according to the JPA specification. If you want left join semantics, you have to code joins explicitly. No idea what Spring Data does.

@IzabellaK If you want to fetch more you have to set the property:

spring.jpa.properties.hibernate.max_fetch_depth

Because the default value is 2.

And I think this property was not used correctly in Hibernate < 6 (because with default value: 2, hibernate fetches much more than two depths) Am I right? @beikov

1 Like

I don’t think that ORM 5 did fetch more with respect to the max fetch depth, but whatever problem anyone faces, please create a reproducer for this so that we can actually take a look at it. Without that, there is nothing anyone can do or help you with.