Hi, I'm using Cayenne 4.2.RC2 and have a special problem when deleting or creating objects that have a relation to others. To solve the problem I have to delete the FK relation on database. I'm using MariaDB 10.9. with the JDBC driver org.mariadb.jdbc 3.1.3.
My model meals meals_meals_items meals_items meals 1 : n meals_items the relation is in meals_meals_items so meals_meals_items has two fk one to meal_id and one to meal_item_id I try to create a meal with two meals_items the log looks like 2023-04-12 08:29:01,423 INFO [org.apache.cayenne.log.JdbcEventLogger]: INSERT INTO `balecon`.`meals_meals_items`( `meal_id`, `meal_item_id`) VALUES( ?, ?) 2023-04-12 08:29:01,423 INFO [org.apache.cayenne.log.JdbcEventLogger]: [batch bind: 1->meal_id:'d845fda8-ad39-47f9-98dd-5062ce...', 2->meal_item_id:'d2b8082f-9318-4a71-b27d-c51ae7...'] 2023-04-12 08:29:01,423 INFO [org.apache.cayenne.log.JdbcEventLogger]: [batch bind: 1->meal_id:'d845fda8-ad39-47f9-98dd-5062ce...', 2->meal_item_id:'67f4bbfe-8837-43c3-b722-aedd29...'] 2023-04-12 08:29:01,435 INFO [org.apache.cayenne.log.JdbcEventLogger]: *** error. java.sql.BatchUpdateException: (conn=19509) Cannot add or update a child row: a foreign key constraint fails (`balecon`.`meals_meals_items`, CONSTRAINT `fk_meals_items` FOREIGN KEY (`meal_item_id`) REFERENCES `meals_items` (`id`)) so cayenne tries to insert the meals_meals_items before the inserts of meals_items? sometimes it works, but then the deleting has problem, also first he trys to delete meals_meals_items then the fk has a problem? regards Meex When I log the JDBC statements I see