It worked fine till version 5.4.10.Final, but with beginning with 5.4.11.Final stopped working. Just for information: we found one change related to that in 5.4.11 is HHH-13760 Closed The problems happens in unit test. We delete data from parent and from child entities. Both uses Envers. The definition of relation to parent in child:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ORGANIZATION_ID", referencedColumnName = "ID")
@NotNull
Hibernate deletes parent entity. Then Envers during processing of child entity tries to find the parent in database (it is also not in cache any more) and throws ObjectNotFoundException:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [net.payback.lmsglobal.organization.core.db.entity.OrganizationEntity#2]
at org.hibernate.boot.internal.StandardEntityNotFoundDelegate.handleEntityNotFound(StandardEntityNotFoundDelegate.java:28)
at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:286)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:181)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:310)
at org.hibernate.envers.internal.entities.mapper.relation.ToOneIdMapper.mapToMapFromEntity(ToOneIdMapper.java:62)
at org.hibernate.envers.internal.entities.mapper.MultiPropertyMapper.map(MultiPropertyMapper.java:90)
at org.hibernate.envers.internal.synchronization.work.DelWorkUnit.generateData(DelWorkUnit.java:53)
at org.hibernate.envers.internal.synchronization.work.AbstractAuditWorkUnit.perform(AbstractAuditWorkUnit.java:66)
at org.hibernate.envers.internal.synchronization.AuditProcess.executeInSession(AuditProcess.java:125)
at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:174)
at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:47)
at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:954)
at org.hibernate.engine.spi.ActionQueue.beforeTransactionCompletion(ActionQueue.java:525)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2371)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:447)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$300(JdbcResourceLocalTransactionCoordinatorImpl.java:40)
It worked find for the last 5 years and stopped to work now. Following newly added in 5.4.10 lines of code from ToOneIdMapper causes a problem:
Object entity = nonInsertableFake ? oldObj : newObj;
if ( lazyMapping && entity instanceof HibernateProxy ) {
entity = ( (HibernateProxy) entity ).getHibernateLazyInitializer().getImplementation();
}
Thanks & best regards. |