issue-113: Fix all Delete Operations #114

Merged
sebastian merged 4 commits from issue-113 into master 2024-04-17 20:25:39 +02:00
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)
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;
@ManyToOne

View File

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

View File

@ -25,7 +25,7 @@ public class Taskgroup {
@JoinColumn(name = "taskgroupuser", nullable = false)
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;
@ManyToOne
@ -33,7 +33,7 @@ public class Taskgroup {
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;
public Taskgroup(String taskgroupName, User user) {

View File

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