diff --git a/.gitignore b/.gitignore index 2ca45ab24..5cba159e8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,5 @@ out/ ### properties ### *.properties + +application.yml \ No newline at end of file diff --git a/src/main/java/org/example/expert/domain/todo/entity/Todo.java b/src/main/java/org/example/expert/domain/todo/entity/Todo.java index b4efcced1..ad1bc2557 100644 --- a/src/main/java/org/example/expert/domain/todo/entity/Todo.java +++ b/src/main/java/org/example/expert/domain/todo/entity/Todo.java @@ -17,7 +17,8 @@ @Table(name = "todos") public class Todo extends Timestamped { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; private String contents; @@ -30,7 +31,7 @@ public class Todo extends Timestamped { @OneToMany(mappedBy = "todo", cascade = CascadeType.REMOVE) private List comments = new ArrayList<>(); - @OneToMany(mappedBy = "todo") + @OneToMany(mappedBy = "todo", cascade = CascadeType.ALL, orphanRemoval = true) private List managers = new ArrayList<>(); public Todo(String title, String contents, String weather, User user) { diff --git a/src/main/java/org/example/expert/domain/todo/service/TodoService.java b/src/main/java/org/example/expert/domain/todo/service/TodoService.java index 922991ce7..bc9811303 100644 --- a/src/main/java/org/example/expert/domain/todo/service/TodoService.java +++ b/src/main/java/org/example/expert/domain/todo/service/TodoService.java @@ -21,10 +21,11 @@ @RequiredArgsConstructor @Transactional(readOnly = true) public class TodoService { - + private final TodoRepository todoRepository; private final WeatherClient weatherClient; + @Transactional public TodoSaveResponse saveTodo(AuthUser authUser, TodoSaveRequest todoSaveRequest) { User user = User.fromAuthUser(authUser);