An entity cannot be annotated with both @Entity and @MappedSuperclass

Asked on May 20, 2013
Hi I am new to Hibernate, got an error , help me to debug,

Caused by: org.hibernate.AnnotationException: An entity cannot be annotated with both @Entity and @MappedSuperclass:
    at org.hibernate.cfg.AnnotationBinder.bindClass(
    at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(
    at org.hibernate.cfg.Configuration.buildSessionFactory(
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(

Replied on May 20, 2013
@Entity and @MappedSuperclass can not be used together.  @Entity maps a class to a database table where as @MappedSuperclass keeps common attribute as super class. Use any one of them according to requirement.

Write Answer

©2024 | Privacy Policy | Contact Us