javax.persistence.PersistenceException: [PersistenceUnit: MappingException] Unable to build Hibernate SessionFactory

Hibernate JIRA | Maxim Frolov | 2 years ago
  1. 0

    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.

    Hibernate JIRA | 2 years ago | Maxim Frolov
    javax.persistence.PersistenceException: [PersistenceUnit: MappingException] Unable to build Hibernate SessionFactory
  2. 0

    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.

    Hibernate JIRA | 2 years ago | Maxim Frolov
    javax.persistence.PersistenceException: [PersistenceUnit: MappingException] Unable to build Hibernate SessionFactory
  3. 0

    Repeated column in mapping for entity exception when trying to use same embeddable twise

    Stack Overflow | 2 years ago
    javax.persistence.PersistenceException: [PersistenceUnit: MyClassRegister] Unable to build Hibernate SessionFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate mapping Exception : unable to find column with logical name

    Stack Overflow | 2 years ago
    javax.persistence.PersistenceException: [PersistenceUnit: MyClassRegister] Unable to build Hibernate SessionFactory
  6. 0

    How to map to attributes from embedded class to a single database column with JPA?

    Stack Overflow | 1 year ago | François Dupire
    javax.persistence.PersistenceException: [PersistenceUnit: belgium-fiscal-model] Unable to build Hibernate SessionFactory
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.MappingException

    property [energiefluss] not found on entity [frol.Portfoliowirkung]

    at org.hibernate.mapping.PersistentClass.getRecursiveProperty()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.mapping.PersistentClass.getRecursiveProperty(PersistentClass.java:442)
    2. org.hibernate.mapping.PersistentClass.getReferencedProperty(PersistentClass.java:382)
    3. org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1724)
    4. org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426)
    5. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
    5 frames
  3. org.hibernate.jpa
    EntityManagerFactoryBuilderImpl$4.perform
    1. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
    2. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1239)
    3. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120)
    4. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:855)
    5. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
    5 frames
  4. org.hibernate.boot
    ClassLoaderServiceImpl.withTccl
    1. org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
    1 frame
  5. org.hibernate.jpa
    HibernatePersistenceProvider.createEntityManagerFactory
    1. org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
    2. org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:75)
    2 frames
  6. Hibernate EJB
    HibernatePersistence.createEntityManagerFactory
    1. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:54)
    1 frame
  7. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    2 frames
  8. frol
    MappingExceptionTest.mappingExceptionTest
    1. frol.MappingExceptionTest.mappingExceptionTest(MappingExceptionTest.java:11)
    1 frame
  9. Java RT
    DelegatingMethodAccessorImpl.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3 frames
  10. JUnit
    JUnitCore.run
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    13. org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    14. org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    14 frames
  11. IntelliJ junit4 module
    JUnit4IdeaTestRunner.startRunnerWithArgs
    1. com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
    1 frame
  12. IDEA
    JUnitStarter.main
    1. com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
    2. com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
    2 frames
  13. Java RT
    NativeMethodAccessorImpl.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    2 frames
  14. IDEA
    AppMain.main
    1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    1 frame