From e21533cee90f154b98d512c355c0f781ef732939 Mon Sep 17 00:00:00 2001 From: Sven Naumann Date: Tue, 19 Oct 2021 15:10:58 +0200 Subject: [PATCH] fix foreign key constraint error deleting project --- .../org/kitodo/production/services/data/ProjectService.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java index 4c9edbb2e3d..81c2b4aa4ff 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java @@ -367,6 +367,10 @@ public static void delete(int projectID) throws DAOException, DataException, Pro user.getProjects().remove(project); ServiceManager.getUserService().saveToDatabase(user); } + for (Template template : project.getTemplates()) { + template.getProjects().remove(project); + ServiceManager.getTemplateService().saveToDatabase(template); + } ServiceManager.getProjectService().remove(project); } }