It seems that Hibernate ignores any @Basic field specified in javax.persistence.fetchgraph and always loads the whole object until we explicitly define the field as @Basic(fecth=LAZY). However the JPA 2.1 standard says:
To specify a fetch graph, set the javax.persistence.fetchgraph property when you execute an EntityManager.find or query operation. A fetch graph consists of only the fields explicitly specified in the EntityGraph instance, and ignores the default entity graph settings.
The problem is that I do not want to set all fields to LAZY load by default since I only need partial objects in some particular cases on massive data fetches for UI. Is there any work-around for this case when I can dynamically specify what to load?
EclipseLink works with fetchgraph as expected.
P.S. Hibernate 5.3.1.Final, bytecode enhancement made with hibernate-gradle-plugin:5.3.1.Final:
hibernate {
enhance {
enableLazyInitialization= true
enableDirtyTracking = true
enableAssociationManagement = true
enableExtendedEnhancement = false
}
}