JPA : AnnotationException: An entity cannot be annotated with both @Entity and @MappedSuperclass: test.BaseEntity

    JPA로 MappedSuperClass를 사용해서 필드 변수를 뿌려주려고 BaseEntity를 등록했다. 등록하는 과정에서 "Exception in thread "main" org.hibernate.AnnotationException: An entity cannot be annotated with both @Entity and @MappedSuperclass: test.BaseEntity" 에러가 발생했다.

    @Entity
    @MappedSuperclass
    public abstract class BaseEntity {
    
        private String createdBy;
        private LocalDateTime createdDate;
        private String lastModifiedBy;
        private LocalDateTime lastModifiedTime;
    
    
    }

    이 때, BaseEntity 클래스를 살펴보면 위와 같다. @MappedSuperclass 어노테이션과 @Entity 어노테이션이 함께 사용되는 것이 확인되었다. 여기서 @MappedSuperclass를 등록해주기 위해 @Entity 어노테이션을 삭제해주었다. @Entity 삭제 후, 정상 실행되는 것을 확인했다. 

     

     

     

    댓글

    Designed by JB FACTORY