I had setup bytecode instrumentation to enable nullable lazy property loading for hibernate 4.3. After the migration to hibernate 5.2.1 the lazy loading behaviour seems to be broken. The configuration I have is: For instrumentation, I've disabled everything I could and only left the lazy loading instrumentation
<plugin>
<groupId>org.hibernate.orm.tooling</groupId>
<artifactId>hibernate-enhance-maven-plugin</artifactId>
<version>${hibernate.version}</version>
<executions>
<execution>
<configuration>
<failOnError>true</failOnError>
<enableLazyInitialization>true</enableLazyInitialization>
<enableDirtyTracking>false</enableDirtyTracking>
<enableAssociationManagement>false</enableAssociationManagement>
<enableExtendedEnhancement>false</enableExtendedEnhancement>
</configuration>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>${jta.version}</version>
</dependency>
</dependencies>
</plugin>
Entity containing the lazy loaded field
@Entity
@Table("BLAH")
class ContainsALazyNullableField {
...
@OneToOne(fetch = FetchType.LAZY, optional = true)
@LazyToOne(LazyToOneOption.NO_PROXY)
@PrimaryKeyJoinColumn
@LazyGroup("groupName")
private TempTableEntity tempTableEntity;
...
}
@Entity
@Table(name = "TEMP_TABLE")
public class TempTableEntity {
@Id
@Column(name = "REGISTRATION_ID")
private String registrationId;
@Column(name = "SORT_ORDER")
private int sortOrder;
...
}
What I get is this:
javax.persistence.EntityNotFoundException: Unable to find com.sflpro.bmis.dto.ReportRegId with id 0000019d-b151-4336-90a5-d41c499f7d30
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$JpaEntityNotFoundDelegate.handleEntityNotFound(EntityManagerFactoryBuilderImpl.java:157)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:262)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:121)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:89)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1213)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:1096)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:639)
at org.hibernate.type.EntityType.resolve(EntityType.java:431)
at org.hibernate.type.EntityType.nullSafeGet(EntityType.java:262)
at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore(AbstractEntityPersister.java:1063)
at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyProperty(AbstractEntityPersister.java:991)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor$1.doWork(LazyAttributeLoadingInterceptor.java:105)
at org.hibernate.bytecode.enhance.spi.interceptor.Helper.performWork(Helper.java:97)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.loadAttribute(LazyAttributeLoadingInterceptor.java:76)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.fetchAttribute(LazyAttributeLoadingInterceptor.java:72)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.intercept(LazyAttributeLoadingInterceptor.java:61)
at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.readObject(LazyAttributeLoadingInterceptor.java:296)
at com.aa.ContainsALazyNullableField.$$_hibernate_read_someOtherLazyField(aaContainsALazyNullableField.java)
at com.aaContainsALazyNullableField.getTempTableEntity(aaContainsALazyNullableField.java:477)
|