Je reçois l'erreur suivanteImpossible d'ajouter ou mettre à jour une ligne enfant: une contrainte de clé étrangère échoue - Liferay
Caused by: org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at com.liferay.portal.dao.orm.hibernate.SessionImpl.flush(SessionImpl.java:144)
... 192 more
Caused by: java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`audit_compliance`.`audit_compliance_auditdetailes`, CONSTRAINT `auditComplianceCompanyId` FOREIGN KEY (`auditComplianceCompanyId`) REFERENCES `audit_compliance_auditcompliancecompany` (`audit)
at com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:2054)
at com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:1467)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1135)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
J'utilise Liferay 6.2. Il n'a pas de clé de mappage dans le générateur de service, donc j'ai manuellement donné la référence dans ma table de base de données. Le référencement est correct, je ne comprends pas la raison pour laquelle il donne une erreur.
ALTER TABLE `audit_compliance`.`audit_compliance_auditdetailes`
DROP FOREIGN KEY `documentCollectionIds`;
ALTER TABLE `audit_compliance`.`audit_compliance_auditdetailes`
ADD CONSTRAINT `documentCollectionIds`
FOREIGN KEY (`documentCollectionIds`)
REFERENCES `audit_compliance`.`audit_compliance_documentcollection` (`name`);