[hibernate-issues] [JIRA] (HHH-13945) Envers cannot process deletion of child entity for ManyToOne relation
Maxim Schelest (JIRA)
jira at hibernate.atlassian.net
Tue Apr 14 06:03:41 EDT 2020
Maxim Schelest ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A8fc4a2d5-ca78-4045-8597-d062d5b2b615 ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 ) HHH-13945 ( https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 ) Envers cannot process deletion of child entity for ManyToOne relation ( https://hibernate.atlassian.net/browse/HHH-13945?atlOrigin=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 )
Issue Type: Bug Affects Versions: 5.4.11 Assignee: Chris Cranford ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3Aea49f1db-ef91-4d96-8f3a-a939be8d2b1c ) 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%3A8fc4a2d5-ca78-4045-8597-d062d5b2b615 )
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=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13945#add-comment?atlOrigin=eyJpIjoiMmZkNDVmMTZlNDQ5NDc0NzhkYmMyYzU3YjBjYTMxNjciLCJwIjoiaiJ9 )
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.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200414/a4be4196/attachment.html
More information about the hibernate-issues
mailing list