An entity cannot is annotated with both @Entity and @MappedSuperclass: Com.example1.demo1.Entity.User error

Source: Internet
Author: User

The project asks the following error in the SPRINGDATAJPA project, which occurs during the run:

caused by:org.hibernate.AnnotationException: An entity cannot is annotated with both @Entity and @MappedSuperclas S: com.example1.demo1.Entity.User at Org.hibernate.cfg.AnnotationBinder.bindClass (Annotationbinder.java: 493) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] At Org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies (Annotationmetadatasourceprocessorimpl.java:249) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] at org.hibernate.boot.model.process.spi.metadatabuildingprocess$1.processEntityHierarchies (metadatabuildingprocess.java:222) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] at Org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete (Metadatabuildingprocess.java: 265) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] at Org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata ( Entitymanagerfactorybuilderimpl.java:861) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] at Org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build ( Entitymanagerfactorybuilderimpl.java:888) ~[hibernate-core-5.2.17.final.jar:5.2.17. Final] At Org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory ( Springhibernatejpapersistenceprovider.java:) ~[spring-orm-5.0.6.release.jar:5.0.6.release]

Workaround:

Removing @mappedsuperclass annotations on an instance class resolves this error, but the following error occurs:

 for Entity:com.example1.demo1.Entity.User

The reason for this error is that the ID primary key is not declared and the program cannot find the primary key to report the error.

However, in some cases, the deletion of this note may also be reported other exceptions, please refer to the following blog:

Https://www.cnblogs.com/itiande/p/9139161.html

An entity cannot is annotated with both @Entity and @MappedSuperclass: Com.example1.demo1.Entity.User error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.