Entity graph (fetch graph) is incorrectly applied to query results beyond the first one


When I apply a fetch graph to a query, it is correctly applied to the first result: eager associations that are not mentioned in the fetch graph are overridden and made lazy.

However, this is not true for query results beyond the first one (index 1, 2, etc.): for those results, eager associations are loaded eagerly, even if they are not mentioned in the fetch graph.

This used to work in 5.4.18.Final.

PR coming, with a test case and hopefully a fix.




Yaroslav Prokipchyn
September 8, 2020, 8:16 PM

I have created an issue and created a small repository to reproduce it.

Thank you.

Nathan Xu
September 7, 2020, 1:22 PM

Without access to real code, my wild guess is the warning does make sense and his code is relying on incorrect code logic previously and now it has been fixed.

But I might be wrong. Yaroslav Prokipchyn, could you confirm? You might either correct your entity graph usage, or file a bug here with details as much as possible so I can take a look?

Yoann Rodière
September 7, 2020, 10:19 AM

I may be wrong, but I believe that's more likely to be a regression caused by than by this ticket. Please create a separate ticket?

do you think you can have a look? You know how entity graphs work better than I do.


Yaroslav Prokipchyn
September 7, 2020, 10:05 AM

Hello. After upgrade spring boot 2.3.2 to 2.3.3 that updated hibernate 4.5.18 to 4.5.20. I start to see hondreds log messages:
[WARN] Entity graph specified is not applicable to the entity ... . Ignored.

@EntityGraph(attributePaths = {...}) is ignored. And I am having banch of N+1 problems because of that.

in org.hibernate.loader.Loader#processResultSet line 1007
property nullSeparatedHydratedObjectsPerRow contains object of different types not only those thet i quering .
and those entries does not pass validation in
if ( fetchGraphContext != null && !fetchGraphContext.appliesTo( entity.getClass() ) ) {

Is this expected behavior.

Nathan Xu
July 29, 2020, 3:03 PM

It is me who trigged this bug while solving another entity graph bug ( ). Previously we set erroneous subgraph. After my code changes, we set subgraph to null correctly for some cases (the bug I fixed in HHH-14097), but incorrectly for other cases as well (the bug reported in this PR).



Yoann Rodière


Yoann Rodière

Fix versions





Suitable for new contributors


Requires Release Note





Affects versions