javax.persistence.PersistenceException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Given the following JPA model: {panel:title=JPA model} {code:title=Buchung.java|borderStyle=solid} @Entity @Inheritance(strategy = javax.persistence.InheritanceType.JOINED) public abstract class Buchung { @Id private Long id; @ManyToOne private Energiefluss energiefluss; } {code} {code:title=Buchung.java|borderStyle=solid} @Entity @Inheritance(strategy = InheritanceType.JOINED) public abstract class Energiefluss { @Id private Long id; @OneToMany(mappedBy = "energiefluss") private List<Buchung> buchungen = new ArrayList<>(); } {code} {code:title=Erzeugungsanlage.java|borderStyle=solid} @Entity public class Erzeugungsanlage extends Energiefluss { @OneToOne(mappedBy = "energiefluss") private Portfoliowirkung portfoliowirkung; } {code} {code:title=Portfoliowirkung.java|borderStyle=solid} @Entity public class Portfoliowirkung extends Buchung { } {code} {panel} The initialization of EntityManagerFactory fails with the following exception: *org.hibernate.MappingException*: property \[*energiefluss*\] not found on entity \[frol.*Portfoliowirkung*\] The full stack trace is: {noformat} javax.persistence.PersistenceException: [PersistenceUnit: MappingException] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1239) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:855) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39) at frol.MappingExceptionTest.mappingExceptionTest(MappingExceptionTest.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: org.hibernate.MappingException: property-ref [energiefluss] not found on entity [frol.Portfoliowirkung] at org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:385) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1724) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) ... 34 more Caused by: org.hibernate.MappingException: property [energiefluss] not found on entity [frol.Portfoliowirkung] at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:442) at org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:382) ... 38 more {noformat} Eclipselink (version 2.5.2) does not throw any exception. See the attached test case. *No exception* is thrown, if * entity _Buch_ has {{SINGLE_TABLE}} inheritance. * entity _Energiefluss_ has {{SINGLE_TABLE}} inheritance. * entities _Buch_ and _Energiefluss_ both have {{SINGLE_TABLE}} inheritance.
    via by Maxim Frolov,
  • Given the following JPA model: {panel:title=JPA model} {code:title=Buchung.java|borderStyle=solid} @Entity @Inheritance(strategy = javax.persistence.InheritanceType.JOINED) public abstract class Buchung { @Id private Long id; @ManyToOne private Energiefluss energiefluss; } {code} {code:title=Buchung.java|borderStyle=solid} @Entity @Inheritance(strategy = InheritanceType.JOINED) public abstract class Energiefluss { @Id private Long id; @OneToMany(mappedBy = "energiefluss") private List<Buchung> buchungen = new ArrayList<>(); } {code} {code:title=Erzeugungsanlage.java|borderStyle=solid} @Entity public class Erzeugungsanlage extends Energiefluss { @OneToOne(mappedBy = "energiefluss") private Portfoliowirkung portfoliowirkung; } {code} {code:title=Portfoliowirkung.java|borderStyle=solid} @Entity public class Portfoliowirkung extends Buchung { } {code} {panel} The initialization of EntityManagerFactory fails with the following exception: *org.hibernate.MappingException*: property \[*energiefluss*\] not found on entity \[frol.*Portfoliowirkung*\] The full stack trace is: {noformat} javax.persistence.PersistenceException: [PersistenceUnit: MappingException] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1239) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:855) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39) at frol.MappingExceptionTest.mappingExceptionTest(MappingExceptionTest.java:11) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: org.hibernate.MappingException: property-ref [energiefluss] not found on entity [frol.Portfoliowirkung] at org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:385) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1724) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852) ... 34 more Caused by: org.hibernate.MappingException: property [energiefluss] not found on entity [frol.Portfoliowirkung] at org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:442) at org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:382) ... 38 more {noformat} Eclipselink (version 2.5.2) does not throw any exception. See the attached test case. *No exception* is thrown, if * entity _Buch_ has {{SINGLE_TABLE}} inheritance. * entity _Energiefluss_ has {{SINGLE_TABLE}} inheritance. * entities _Buch_ and _Energiefluss_ both have {{SINGLE_TABLE}} inheritance.
    via by Maxim Frolov,
    • javax.persistence.PersistenceException: [PersistenceUnit: junit] Unable to build Hibernate SessionFactory at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194) at org.apache.tools.ant.taskdefs.Java.run(Java.java:771) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221) at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135) at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor264.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38) at org.eclipse.ant.internal.core.ant.EclipseSingleCheckExecutor.executeTargets(EclipseSingleCheckExecutor.java:34) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.eclipse.ant.internal.core.ant.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:36) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:705) at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:527) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.ant.core.AntRunner.run(AntRunner.java:371) at org.eclipse.ant.internal.launching.launchConfigurations.AntLaunchDelegate$1.run(AntLaunchDelegate.java:269) at java.lang.Thread.run(Unknown Source) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: junit] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55) at org.openxava.jpa.XPersistence.getEntityManagerFactory(XPersistence.java:197) at org.openxava.jpa.XPersistence.createManager(XPersistence.java:112) at org.openxava.jpa.XPersistence.openManager(XPersistence.java:128) at org.openxava.jpa.XPersistence.getManager(XPersistence.java:98) at org.openxava.tools.SchemaTool.execute(SchemaTool.java:75) at org.openxava.tools.SchemaTool.updateSchema(SchemaTool.java:53) at org.openxava.tools.SchemaTool.main(SchemaTool.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217) at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152) ... 40 more Caused by: org.hibernate.MappingException: Could not determine type for: org.openxava.school.model.Level1, at table: Level3 at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:349) at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:353) at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:71) at org.hibernate.mapping.Component.getType(Component.java:180) at org.hibernate.tuple.PropertyFactory.buildStandardProperty(PropertyFactory.java:353) at org.hibernate.tuple.component.ComponentMetamodel.<init>(ComponentMetamodel.java:71) at org.hibernate.mapping.Component.getType(Component.java:180) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:322) at org.hibernate.mapping.RootClass.validate(RootClass.java:271) at org.hibernate.cfg.Configuration.validate(Configuration.java:1360) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1851) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857) ... 59 more

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor2 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    50 more bugmates