본문 바로가기
개발일기/project

[Troubleshooting] #2 JPA의 동작과 WARN 레벨 로그 수정

by 햄리뮤 2025. 1. 14.
반응형

오늘은 아무것도 설정하지 않고 유저 회원 가입 및 유저 관련한 개발을 하였고 하고있따....

https://www.jordan.network.global/en/troubleshooting.jsp


문제:

2025-01-14T20:39:46.012+09:00  WARN 27560 --- [console-service] [           main] org.hibernate.mapping.RootClass          : HHH000038: Composite-id class does not override equals(): cohttp://m.lima.consoleservice.domain.repository.entity.UserCredentials
2025-01-14T20:39:46.013+09:00  WARN 27560 --- [console-service] [           main] org.hibernate.mapping.RootClass          : HHH000039: Composite-id class does not override hashCode(): cohttp://m.lima.consoleservice.domain.repository.entity.UserCredentials

WARN 레벨 이지만  신경이 쓰여서 무엇인지 확인하였다!

에러 원인:

나는 지금 JPA를 사용하고있는데 Hibernate 에서 복합키(여러개의 필드를 사용하여 엔티티의 고유한 식별자를 구성)를 사용하는 엔티티 클래스인 UserCredentials가 equals()와 hashCode() 메서드를 오버라이드 하지 않았다고 경고를 주고있었다.

나는 Lombok도 사용하지 않고 있어서 @Data라는 애노테이션도 없었고 equals()와 hashCode()를 구현하지 않아도 되겠지 라는 생각에 하지 않았다.

Composite-id class does not override equals()
Composite-id class does not override hashCode(): 

에러 원인의 결론은 JPA의 구동 방식에 대해서 몰랐던 부분이 있었기에 해당 WARN이 발생 했다는것 이다!

해결:

시키는대로 UserCredentials 클래스에 equals()와 hashCode() 메서드를 오버라이드(꼭 둘다 해줘야함!) 하면 해결이 된다!

 

 

** 그냥 하루하루 개인 공부한 것을 끄적 거리는 공간입니다.

이곳 저곳에서 구글링한 것과 강의 들은 내용이 정리가 되었습니다.

그림들은 그림밑에 출처표시를 해놓았습니다.

문제가 될시 말씀해주시면 해당 부분은 삭제 하도록하겠습니다. **

 

반응형

댓글