java.sql.BatchUpdateException

Cannot add or update a child row: a foreign key constraint fails (`mc_pex`.`pex_inheritance`, CONSTRAINT `inheritance_segment_fk` FOREIGN KEY (`segment`) REFERENCES `pex_segments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) Query is: INSERT INTO pex_inheritance (`segment`, `parent`) VALUES (?, ?)

Samebug tips1

It was a database inconsistency issue in the integration test dataset.

Don't give up yet. Our experts can help. Paste your full stack trace to get a solution.

Solutions on the web1117

  • Cannot add or update a child row: a foreign key constraint fails (`mc_pex`.`pex_inheritance`, CONSTRAINT `inheritance_segment_fk` FOREIGN KEY (`segment`) REFERENCES `pex_segments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) Query is: INSERT INTO pex_inheritance (`segment`, `parent`) VALUES (?, ?)
  • Cannot add or update a child row: a foreign key constraint fails (`phonebookdb`.`role`, CONSTRAINT `role_ibfk_5` FOREIGN KEY (`ROLA_ID`) REFERENCES `korisnici` (`KORISNIK_ID`) ON DELETE CASCADE ON UPDATE CASCADE)
  • via GitHub by Naghtrion
    , 7 months ago
    Cannot add or update a child row: a foreign key constraint fails (`mc_151`.`mh_Daily`, CONSTRAINT `mh_Daily_Player_Id` FOREIGN KEY (`PLAYER_ID`) REFERENCES `mh_PlayersV2` (`PLAYER_ID`) ON DELETE CASCADE)
  • Stack trace

    • java.sql.BatchUpdateException: Cannot add or update a child row: a foreign key constraint fails (`mc_pex`.`pex_inheritance`, CONSTRAINT `inheritance_segment_fk` FOREIGN KEY (`segment`) REFERENCES `pex_segments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) Query is: INSERT INTO pex_inheritance (`segment`, `parent`) VALUES (?, ?) at org.mariadb.jdbc.MariaDbServerPreparedStatement.executeInternal(MariaDbServerPreparedStatement.java:340)[MariaDbServerPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.MariaDbServerPreparedStatement.execute(MariaDbServerPreparedStatement.java:304)[MariaDbServerPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.MariaDbServerPreparedStatement.executeUpdate(MariaDbServerPreparedStatement.java:293)[MariaDbServerPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)[ProxyPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)[HikariProxyPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] at ninja.leaping.permissionsex.backend.sql.SqlDao.addParent(SqlDao.java:643)[SqlDao.class:?] at ninja.leaping.permissionsex.backend.sql.Segment.lambda$withAddedParent$9(Segment.java:166)[Segment.class:?] at ninja.leaping.permissionsex.backend.sql.Segment.doUpdates(Segment.java:199)[Segment.class:?] at ninja.leaping.permissionsex.backend.sql.SqlSubjectData.lambda$newWithUpdated$3(SqlSubjectData.java:81)[SqlSubjectData.class:?] at ninja.leaping.permissionsex.backend.sql.SqlSubjectData.lambda$doUpdates$17(SqlSubjectData.java:293)[SqlSubjectData.class:?] at ninja.leaping.permissionsex.backend.sql.SqlDao.executeInTransaction(SqlDao.java:224)[SqlDao.class:?] at ninja.leaping.permissionsex.backend.sql.SqlSubjectData.doUpdates(SqlSubjectData.java:289)[SqlSubjectData.class:?] at ninja.leaping.permissionsex.backend.sql.SqlDataStore.lambda$setDataInternal$4(SqlDataStore.java:227)[SqlDataStore.class:?] at ninja.leaping.permissionsex.util.Util.lambda$asyncFailableFuture$1(Util.java:93)[Util.class:?] at org.spongepowered.api.scheduler.Task$Builder.lambda$execute$0(Task.java:138)[Task$Builder.class:1.10.2-2052-5.0.0-BETA-1670] at org.spongepowered.common.scheduler.SchedulerBase.lambda$startTask$0(SchedulerBase.java:177)[SchedulerBase.class:1.10.2-2052-5.0.0-BETA-1670] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)[?:1.8.0_91] at java.util.concurrent.FutureTask.run(Unknown Source)[?:1.8.0_91] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)[?:1.8.0_91] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)[?:1.8.0_91] at java.lang.Thread.run(Unknown Source)[?:1.8.0_91] Caused by: java.sql.SQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`mc_pex`.`pex_inheritance`, CONSTRAINT `inheritance_segment_fk` FOREIGN KEY (`segment`) REFERENCES `pex_segments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) Query is: INSERT INTO pex_inheritance (`segment`, `parent`) VALUES (?, ?) at org.mariadb.jdbc.internal.util.ExceptionMapper.get(ExceptionMapper.java:119)[ExceptionMapper.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.internal.util.ExceptionMapper.throwException(ExceptionMapper.java:69)[ExceptionMapper.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.MariaDbStatement.executeQueryEpilog(MariaDbStatement.java:242)[MariaDbStatement.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.MariaDbServerPreparedStatement.executeInternal(MariaDbServerPreparedStatement.java:336)[MariaDbServerPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] ... 20 more Caused by: org.mariadb.jdbc.internal.util.dao.QueryException: Cannot add or update a child row: a foreign key constraint fails (`mc_pex`.`pex_inheritance`, CONSTRAINT `inheritance_segment_fk` FOREIGN KEY (`segment`) REFERENCES `pex_segments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE) Query is: INSERT INTO pex_inheritance (`segment`, `parent`) VALUES (?, ?) at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:939)[AbstractQueryProtocol.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executePreparedQuery(AbstractQueryProtocol.java:377)[AbstractQueryProtocol.class:1.10.2-2052-5.0.0-BETA-1670] at org.mariadb.jdbc.MariaDbServerPreparedStatement.executeInternal(MariaDbServerPreparedStatement.java:326)[MariaDbServerPreparedStatement.class:1.10.2-2052-5.0.0-BETA-1670] ... 20 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    2 times, 5 months ago
    2 times, 2 months ago
    6 times, 2 months ago
    Once, 2 months ago
    4 times, 2 months ago
    1 more bugmates