Maxim Schelest (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmZkNDVmMTZl...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkND...
) HHH-13945 (
https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkND...
) Envers cannot process deletion of child entity for ManyToOne relation (
https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkND...
)
Issue Type: Bug Affects Versions: 5.4.11 Assignee: Chris Cranford (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: hibernate-envers Created: 14/Apr/2020 03:03 AM Environment: JDK 8, Win,
OracleDB Labels: Envers Priority: Blocker Reporter: Maxim Schelest (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
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
(
https://hibernate.atlassian.net/browse/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.
(
https://hibernate.atlassian.net/browse/HHH-13945#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-13945#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )