TroubleShooting

Multiple representations of the same entity [com.example.queyrdsl.entity.Staff#2] are being merged

에디개발자 2020. 11. 6. 13:11
반응형

JPA 정리 도중 에러 발생!

Repository를 이용하여 save할 시 발생했던 에러다. 

 

원인은 간단하다. @OneToMany 관계에서 Many에 해당하는 Entity를 save할때 문제가 발생했다. Entity는 고유하다! 하지만 난 2개의 Entity @Id 컬럼에 같은 값을 넣고 save하는 중이었다. JPA가 같은 Entity가 들어왔으니 위와 같은 에러를 보여준 것이다.

 

해결은 @Id 컬럼의 값을 수정했다.

반응형