[JIRA] (HHH-16244) Cannot delete entities with one-to-one and bidirectional one-to-many relationship
by Milad (JIRA)
Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYTk3YjE0YWU2... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiYTk3Yj... ) HHH-16244 ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiYTk3Yj... ) Cannot delete entities with one-to-one and bidirectional one-to-many relationship ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiYTk3Yj... )
Change By: Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I have {{EntityA}} and {{EntityB}}. There exist the following relationships:
* One-to-one relationship from {{EntityA}} to {{EntityB}}.
* Bidirectional one-to-many relationship from {{EntityA}} to {{EntityB}}.
To remove both entities, I first clear all references, then call {{session.remove()}} on both entities. This results in this exception:
{noformat}jakarta.persistence.PersistenceException: Converting `org.hibernate.exception.ConstraintViolationException` to JPA `PersistenceException` : could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:175)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:182)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1429)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:477)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2234)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1930)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:439)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.bugs.ORMUnitTestCase.hhh123Test(ORMUnitTestCase.java:110)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:60)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:39)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3763)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:4116)
at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:126)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:612)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:483)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:480)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1425)
... 23 more
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referentielle Integritõt verletzt: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"
Referential integrity constraint violation: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"; SQL statement:
delete from EntityB where EntityBId=? [23503-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:508)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:365)
at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:382)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:256)
at org.h2.table.Table.fireConstraints(Table.java:1172)
at org.h2.table.Table.fireAfterRow(Table.java:1190)
at org.h2.command.dml.Delete.update(Delete.java:92)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:209)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:169)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
... 35 more{noformat}
Interestingly, the exception does not occur when I don't manually clear the one-to-one relationship before calling {{session.remove()}} on both entities. But, as in our project, we have the structure to remove all references manually before removing entities, this is required for us.
See attached reproduction based on template [https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/...].
( https://hibernate.atlassian.net/browse/HHH-16244#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16244#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )
1 year, 10 months
[JIRA] (HHH-16244) Cannot delete entities with one-to-one and bidirectional one-to-many relationship
by Milad (JIRA)
Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *updated* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTgzOWQzZWQx... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiZTgzOW... ) HHH-16244 ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiZTgzOW... ) Cannot delete entities with one-to-one and bidirectional one-to-many relationship ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiZTgzOW... )
Change By: Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I have {{EntityA}} and {{EntityB}}. There exist the following relationships:
* One-to-one relationship from {{EntityA}} to {{EntityB}}.
* Bidirectional one-to-many relationship from {{EntityA}} to {{EntityB}}.
To remove both entities, I first clear all references, then call {{session.remove()}} on both entities. This results in this exception:
{noformat}jakarta.persistence.PersistenceException: Converting `org.hibernate.exception.ConstraintViolationException` to JPA `PersistenceException` : could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:175)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:182)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1429)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:477)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2234)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1930)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:439)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.bugs.ORMUnitTestCase.hhh123Test(ORMUnitTestCase.java:110)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:60)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:39)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3763)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:4116)
at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:126)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:612)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:483)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:480)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1425)
... 23 more
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referentielle Integritõt verletzt: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"
Referential integrity constraint violation: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"; SQL statement:
delete from EntityB where EntityBId=? [23503-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:508)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:365)
at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:382)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:256)
at org.h2.table.Table.fireConstraints(Table.java:1172)
at org.h2.table.Table.fireAfterRow(Table.java:1190)
at org.h2.command.dml.Delete.update(Delete.java:92)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:209)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:169)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
... 35 more{noformat}
See attached reproduction based on template [https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/...] :.
( https://hibernate.atlassian.net/browse/HHH-16244#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16244#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )
1 year, 10 months
[JIRA] (HHH-16244) Cannot delete entities with one-to-one and bidirectional one-to-many relationship
by Milad (JIRA)
Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODdmNTI5M2M3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiODdmNT... ) HHH-16244 ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiODdmNT... ) Cannot delete entities with one-to-one and bidirectional one-to-many relationship ( https://hibernate.atlassian.net/browse/HHH-16244?atlOrigin=eyJpIjoiODdmNT... )
Issue Type: Bug Affects Versions: 6.1.7 Assignee: Unassigned Attachments: reproduction.zip Components: hibernate-orm-modules Created: 02/Mar/2023 05:43 AM Environment: Hibernate 6.1.7.Final. Unit test case provided with template https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/... ( https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/... ) Priority: Blocker Reporter: Milad ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
I have EntityA and EntityB. There exist the following relationships:
* One-to-one relationship from EntityA to EntityB.
* Bidirectional one-to-many relationship from EntityA to EntityB.
To remove both entities, I first clear all references, then call session.remove() on both entities. This results in this exception:
jakarta.persistence.PersistenceException: Converting `org.hibernate.exception.ConstraintViolationException` to JPA `PersistenceException` : could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:175)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:182)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1429)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:477)
at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2234)
at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:1930)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:439)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:183)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:281)
at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:101)
at org.hibernate.bugs.ORMUnitTestCase.hhh123Test(ORMUnitTestCase.java:110)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:60)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:56)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:39)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:3763)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:4116)
at org.hibernate.action.internal.EntityDeleteAction.execute(EntityDeleteAction.java:126)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:612)
at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:483)
at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:480)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:329)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1425)
... 23 more
Caused by: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referentielle Integritõt verletzt: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"
Referential integrity constraint violation: "FK8QCPYR2C217Q3RPPCGGGR7ST3: PUBLIC.ENTITYA FOREIGN KEY(SELECTEDENTITYBID) REFERENCES PUBLIC.ENTITYB(ENTITYBID) (2)"; SQL statement:
delete from EntityB where EntityBId=? [23503-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:508)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:365)
at org.h2.constraint.ConstraintReferential.checkRowRefTable(ConstraintReferential.java:382)
at org.h2.constraint.ConstraintReferential.checkRow(ConstraintReferential.java:256)
at org.h2.table.Table.fireConstraints(Table.java:1172)
at org.h2.table.Table.fireAfterRow(Table.java:1190)
at org.h2.command.dml.Delete.update(Delete.java:92)
at org.h2.command.dml.DataChangeStatement.update(DataChangeStatement.java:74)
at org.h2.command.CommandContainer.update(CommandContainer.java:169)
at org.h2.command.Command.executeUpdate(Command.java:252)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:209)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:169)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
... 35 more
See reproduction based on template https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/... ( https://github.com/hibernate/hibernate-test-case-templates/tree/main/orm/... ) :
( https://hibernate.atlassian.net/browse/HHH-16244#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16244#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )
1 year, 10 months
[JIRA] (HSEARCH-4810) Fix flaky test with MSSQL
by Yoann Rodière (JIRA)
Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate Search ( https://hibernate.atlassian.net/browse/HSEARCH?atlOrigin=eyJpIjoiMGIzNTRl... ) / Task ( https://hibernate.atlassian.net/browse/HSEARCH-4810?atlOrigin=eyJpIjoiMGI... ) HSEARCH-4810 ( https://hibernate.atlassian.net/browse/HSEARCH-4810?atlOrigin=eyJpIjoiMGI... ) Fix flaky test with MSSQL ( https://hibernate.atlassian.net/browse/HSEARCH-4810?atlOrigin=eyJpIjoiMGI... )
Issue Type: Task Assignee: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) Components: integration, tests Created: 02/Mar/2023 02:26 AM Fix Versions: 6.2-backlog Priority: Major Reporter: Yoann Rodière ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
https://ci.hibernate.org/job/hibernate-search/job/main/614/ ( https://ci.hibernate.org/job/hibernate-search/job/main/614/ )
Non-default environments / database-mssql / org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.automaticindexing.OutboxPollingAutomaticIndexingLifecycleIT(coord-outbox-jakarta-database-mssql).stopWhileOutboxEventsIsBeingProcessed ( https://ci.hibernate.org/job/hibernate-search/job/main/614/testReport/jun... )
jakarta.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1626)
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1665)
at org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.testsupport.util.OutboxEventFilter.countOutboxEventsNoFilter(OutboxEventFilter.java:113)
at org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.automaticindexing.OutboxPollingAutomaticIndexingLifecycleIT.lambda$stopWhileOutboxEventsIsBeingProcessed$2(OutboxPollingAutomaticIndexingLifecycleIT.java:80)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.PersistenceRunner.lambda$runInTransaction$2(PersistenceRunner.java:43)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.PersistenceRunner.lambda$applyInTransaction$1(PersistenceRunner.java:36)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.NativePersistenceRunner.lambda$applyInTransaction$0(NativePersistenceRunner.java:43)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmUtils.applyInTransaction(OrmUtils.java:49)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.NativePersistenceRunner.lambda$applyInTransaction$1(NativePersistenceRunner.java:42)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.NativePersistenceRunner.applyNoTransaction(NativePersistenceRunner.java:33)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.NativePersistenceRunner.applyInTransaction(NativePersistenceRunner.java:40)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.PersistenceRunner.applyInTransaction(PersistenceRunner.java:36)
at org.hibernate.search.util.impl.integrationtest.mapper.orm.PersistenceRunner.runInTransaction(PersistenceRunner.java:42)
at org.hibernate.search.integrationtest.mapper.orm.coordination.outboxpolling.automaticindexing.OutboxPollingAutomaticIndexingLifecycleIT.lambda$stopWhileOutboxEventsIsBeingProcessed$3(OutboxPollingAutomaticIndexingLifecycleIT.java:79)
at org.awaitility.core.AssertionCondition.lambda$new$0(AssertionCondition.java:53)
at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.loader.Loader.doList(Loader.java:2871)
at org.hibernate.loader.Loader.doList(Loader.java:2850)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
at org.hibernate.loader.Loader.list(Loader.java:2677)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1459)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
... 20 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: An error occurred during the current command (Done status 0). Transaction (Process ID 64) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:237)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet$FetchBuffer$FetchBufferTokenHandler.onDone(SQLServerResultSet.java:5396)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:99)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:37)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet$FetchBuffer.nextRow(SQLServerResultSet.java:5491)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.fetchBufferNext(SQLServerResultSet.java:1796)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(SQLServerResultSet.java:1054)
at org.hibernate.loader.Loader.getRowsFromResultSet(Loader.java:1043)
at org.hibernate.loader.Loader.processResultSet(Loader.java:998)
at org.hibernate.loader.Loader.doQuery(Loader.java:967)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
at org.hibernate.loader.Loader.doList(Loader.java:2868)
... 29 more
( https://hibernate.atlassian.net/browse/HSEARCH-4810#add-comment?atlOrigin... ) Add Comment ( https://hibernate.atlassian.net/browse/HSEARCH-4810#add-comment?atlOrigin... )
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:65be9f2 )
1 year, 10 months