@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name=”commentId”)
public List getReplyList() {
return replyList;
}

OneToMany를 써서 리스트중의 엔티티빈을 삭제하려고 하면, javax.persistence.EntityNotFoundException: deleted entity passed to persist 에러가 발생한다.

해결방법은

@OneToMany(cascade={CascadeType.MERGE,CascadeType.REMOVE}, fetch=FetchType.EAGER)
@JoinColumn(name=”commentId”)
public List getReplyList() {
return replyList;
}

와 같이 cascade 를 변경해준다.

This entry was posted in Java. Bookmark the permalink.