댓글작성 및 삭제를 할 때 카운트를 하기 위해 Question 정보가 필요한대
댓글이 참조하고 있는 Question 데이터르 answer.getQuestion();
통해 불러왔더니
null임을 확인할 수 있었다..
@PostMapping("") // 댓글작성하고 버튼 눌렀을 때
public Answer createAnswer(Answer answer, @PathVariable("question.id") Long questionId, HttpSession session) {
Question questionData = questionService.findById(questionId);
Question questionData2 = answer.getQuestion();
if(questionData.equals(questionData2)){
System.err.println("똑같음");
System.err.println("똑같음");
System.err.println("똑같음");
System.err.println("똑같음");
System.err.println("똑같음");
System.err.println("똑같음");
}else{
System.err.println("다름");
System.err.println("다름");
System.err.println("다름");
System.err.println("다름");
System.err.println("다름");
System.err.println("다름");
}
https://www.youtube.com/watch?v=E_Iov1Vd2TU&feature=youtu.be
답변 수 구현 방법
Integer countOfAnswer
)를 관리양방향참조를 제대로 안해주고 @JsonIgnore
식으로 때웠더니
여기서 문제가 생긴 것 같다.
댓글을 생성할 때, question에 접근을 해야하는데, id정보말고 올바른게 하나도 없다.
날짜정보의 경우 게시글의 작성일이 아닌 댓글 작성일이 표시돼는데...
삭제에 필요한 정보는 아이디니까 미션 수행은 가능하므로, 일단 지나가자.
미션을 완료하고나면 양방향참조
에 대해서 공부를 해봐야할 것 같다.