Cosium / spring-data-jpa-entity-graph

Spring Data JPA extension allowing full dynamic usage of EntityGraph on repositories
MIT License
466 stars 51 forks source link

Use entity graph type LOAD instead of FETCH #35

Closed devnied closed 4 years ago

devnied commented 4 years ago

Hibernate 5.4.11 have introduce a breaking change in QueryHint for entity graph. (see https://hibernate.atlassian.net/browse/HHH-8776)

Previously, attributes that are not specified in the entity graph are treated as FetchType.LAZY or FetchType.EAGER depending on the attribute's definition in annotation. So "fetchgraph" and "loadgraph" was identical.

Now, with fetchgraph QueryHint, hibernate fetch only attributes included in the entity graph. So attributes not included in the graph should stay unloaded, even if they are declared EAGER.

To keep compatibility with previous version of spring-data-jpa-entity-graph I have switch the default entity graph type to LOAD and add a new method in EntityGraphUtils.java to be able to choose the EntityGraphType.

reda-alaoui commented 4 years ago

Thanks a lot !