Referential integrity constraint violation: "FK_SUPER_ENTITY_MAPPING_SUPER_ENTITY: PUBLIC.GEN_SUPER_ENTITY_MAPPING FOREIGN KEY(SUPER_ENTITY_ID) REFERENCES PUBLIC.GEN_ENTITY(ID) (CAST(2 AS BIGINT))"; SQL statement:
delete from GEN_ENTITY
where
MODEL_ID = ? [23503-224]
org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Referential integrity constraint violation: "FK_SUPER_ENTITY_MAPPING_SUPER_ENTITY: PUBLIC.GEN_SUPER_ENTITY_MAPPING FOREIGN KEY(SUPER_ENTITY_ID) REFERENCES PUBLIC.GEN_ENTITY(ID) (CAST(2 AS BIGINT))"; SQL statement:
delete from GEN_ENTITY
where
MODEL_ID = ? [23503-224]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:520)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:489)
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:1200)
at org.h2.table.Table.fireAfterRow(Table.java:1218)
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:256)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:216)
at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:174)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.babyfish.jimmer.sql.runtime.DefaultExecutor.execute(DefaultExecutor.java:31)
at org.babyfish.jimmer.sql.runtime.ExecutorForLog.prettyLog(ExecutorForLog.java:129)
at org.babyfish.jimmer.sql.runtime.ExecutorForLog.execute(ExecutorForLog.java:47)
at org.babyfish.jimmer.sql.ast.impl.mutation.AbstractAssociationOperator.execute(AbstractAssociationOperator.java:33)
at org.babyfish.jimmer.sql.ast.impl.mutation.AbstractAssociationOperator.execute(AbstractAssociationOperator.java:48)
at org.babyfish.jimmer.sql.ast.impl.mutation.ChildTableOperator.disconnectImpl(ChildTableOperator.java:214)
at org.babyfish.jimmer.sql.ast.impl.mutation.ChildTableOperator.disconnect(ChildTableOperator.java:193)
at org.babyfish.jimmer.sql.ast.impl.mutation.ChildTableOperator.disconnect(ChildTableOperator.java:112)
at org.babyfish.jimmer.sql.ast.impl.mutation.Deleter.execute(Deleter.java:152)
at org.babyfish.jimmer.sql.ast.impl.mutation.DeleteCommandImpl.executeImpl(DeleteCommandImpl.java:53)
at org.babyfish.jimmer.spring.cfg.support.SpringConnectionManager.execute(SpringConnectionManager.java:31)
at org.babyfish.jimmer.sql.ast.impl.mutation.DeleteCommandImpl.execute(DeleteCommandImpl.java:38)
at org.babyfish.jimmer.sql.ast.impl.mutation.DeleteCommandImpl.execute(DeleteCommandImpl.java:17)
at org.babyfish.jimmer.sql.kt.impl.KEntitiesImpl.delete(KEntitiesImpl.kt:253)
at org.babyfish.jimmer.sql.kt.KEntities.delete$default(KEntities.kt:106)
at org.babyfish.jimmer.sql.kt.KSqlClient.deleteById(KSqlClient.kt:222)
at org.babyfish.jimmer.sql.kt.KSqlClient.deleteById$default(KSqlClient.kt:221)
at com.example.TestDelete.test(TestDelete.kt:15)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
环境
抛出异常
延续 Issue #647 的实体结构,在应用批量删除后,出现外键约束报错。
复现
reappear-batch-delete-foreign-key-exception.zip