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