@Query("UPDATE #{#entityName} a SET a.isActive=false WHERE a.id=?1")
@ModifyingvoidsoftDelete(Longid);
@Overridedefaultvoiddelete(Useruser) {
softDelete(user.getId());
}
현재 Question의 글쓴이는 User의 name 값을 가지는 것으로 구현했다.
이와 같이 구현하는 경우 User의 name을 수정하는 경우 Question의 글쓴이와 다른 값을 가지는 문제가 발생한다.
이 문제를 해결하기 위해 User의 name이 변경될 때마다 Question의 writer 값을 수정할 수도 있지만 이와 같이 구현할 경우 writer가 같은 이름을 가지는 경우 문제가 될 수 있다.
User의 id를 저장하는 방법
User의 primary key인 id 값을 Question에 저장한다.
Question을 조회할 때 id 값을 통해 User도 같이 조회한다.