Home  >  Forum  >  Hibernate
Post New Query

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


joined on
April 23,2013
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(AnnotationBinder.java:510)
    at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:636)
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:359)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
joined on
March 18,2013
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









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us