Merge pull request 'issue-113: Fix all Delete Operations' (#114) from issue-113 into master
All checks were successful
Java CI with Maven / build-and-push-frontend (push) Successful in 2m19s
Java CI with Maven / build-and-push-backend (push) Successful in 1m14s

Reviewed-on: #114
This commit is contained in:
sebastian 2024-04-17 20:25:39 +02:00
commit 0d3ba5d7d7
4 changed files with 4 additions and 11 deletions

View File

@ -34,7 +34,7 @@ public class Task {
@OneToOne(mappedBy = "task", cascade = CascadeType.ALL, orphanRemoval = true) @OneToOne(mappedBy = "task", cascade = CascadeType.ALL, orphanRemoval = true)
private TaskSerieItem taskSerieItem; private TaskSerieItem taskSerieItem;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) @OneToMany(mappedBy = "parent", cascade = CascadeType.REMOVE, orphanRemoval = true, fetch = FetchType.EAGER)
private Set<Task> subtasks; private Set<Task> subtasks;
@ManyToOne @ManyToOne

View File

@ -15,9 +15,6 @@ public class TaskSerie {
@OneToMany(fetch = FetchType.EAGER, mappedBy = "taskSerie", orphanRemoval = true) @OneToMany(fetch = FetchType.EAGER, mappedBy = "taskSerie", orphanRemoval = true)
List<TaskSerieItem> tasks = new ArrayList<>(); List<TaskSerieItem> tasks = new ArrayList<>();
public long getTaskSerieID() { public long getTaskSerieID() {
return taskSerieID; return taskSerieID;
} }

View File

@ -25,7 +25,7 @@ public class Taskgroup {
@JoinColumn(name = "taskgroupuser", nullable = false) @JoinColumn(name = "taskgroupuser", nullable = false)
private User user; private User user;
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) @OneToMany(mappedBy = "parent", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, orphanRemoval = true)
private Set<Taskgroup> children; private Set<Taskgroup> children;
@ManyToOne @ManyToOne
@ -33,7 +33,7 @@ public class Taskgroup {
private Taskgroup parent; private Taskgroup parent;
@OneToMany(mappedBy = "taskgroup", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) @OneToMany(mappedBy = "taskgroup", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER, orphanRemoval = true)
private Set<Task> tasks; private Set<Task> tasks;
public Taskgroup(String taskgroupName, User user) { public Taskgroup(String taskgroupName, User user) {

View File

@ -135,11 +135,7 @@ public class TaskSeriesService {
task.setTaskSerieItem(null); task.setTaskSerieItem(null);
taskSerieItemRepository.delete(item); taskSerieItemRepository.delete(item);
if(taskSerie.getTasks().isEmpty()) { if(taskSerie.getTasks().isEmpty()) {
for(TaskSerieItem taskSerieItem : taskSerie.getTasks()) { taskSeriesRepository.deleteUnreferenced();
taskSerieItem.setTaskSerie(null);
}
taskSerie.getTasks().clear();
taskSeriesRepository.delete(taskSerie);
} else if(task.getParent() == null){ } else if(task.getParent() == null){
repearIndexing(taskSerie, item.getSeriesIndex()); repearIndexing(taskSerie, item.getSeriesIndex());
} }