기타/오류

[Problem] org.hibernate.id.IdentifierGenerationException

배발자 2023. 1. 7.

목차

    반응형
    javax.persistence.PersistenceException: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.example.demo.dto.Member at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188) at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:726) at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:706) at com.example.demo.DemoApplication.main(DemoApplication.java:44) Caused by: org.hibernate.id.IdentifierGenerat

     

    em.persist()를 사용할 때 발생한 문제이다. 

     

    [Problem] org.hibernate.id.IdentifierGenerationException

     

    @GeneratedValue 어노테이션이 설정되어 있어야 하는데 @Generated 어노테이션이 설정되어 있었다.

    따라서 해당 어노테이션을 @GeneratedValue로 바꿔주는 것으로 error를 해결할 수 있다. 

     

    [Problem] org.hibernate.id.IdentifierGenerationException

     

    추가적으로 실행했을 때 또 안된다면 DB 설정에서 테이블의 PK 컬럼이 AutoIncrement 로 설정되어 있는지 확인해보자. 

    반응형

    댓글