javax.persistence.PersistenceException: [PersistenceUnit: testunit] Unable to build EntityManagerFactory

Hibernate JIRA | Daniel Nuß | 3 years ago
  1. 0

    When trying to register a Composite UserType in a Integrator via configuration.registerTypeOverride, the creation of the entityManager fails while validating the mapping of such a type with a MappingException: "mapping has wrong number of columns" (see full stack trace below). The problem seems to be, that the registered type is not available in the TypeRegistry while doing this check, so the type is broken down to SerializableType, for which only one column is expected, not several columns as defined in the CompositeType. I tested this with the Jadira UserTypes, but initially had this bug with my own Composite UserType. I'll attach a small test case which reproduces the mentioned issue. Full StackTrace: javax.persistence.PersistenceException: [PersistenceUnit: testunit] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at com.usertyperegistration.FooTest.setUpClass(FooTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: com.usertyperegistration.Foo.bar type: org.joda.time.Interval at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:484) at org.hibernate.mapping.RootClass.validate(RootClass.java:270) at org.hibernate.cfg.Configuration.validate(Configuration.java:1324) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1786) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ... 21 more

    Hibernate JIRA | 3 years ago | Daniel Nuß
    javax.persistence.PersistenceException: [PersistenceUnit: testunit] Unable to build EntityManagerFactory
  2. 0

    When trying to register a Composite UserType in a Integrator via configuration.registerTypeOverride, the creation of the entityManager fails while validating the mapping of such a type with a MappingException: "mapping has wrong number of columns" (see full stack trace below). The problem seems to be, that the registered type is not available in the TypeRegistry while doing this check, so the type is broken down to SerializableType, for which only one column is expected, not several columns as defined in the CompositeType. I tested this with the Jadira UserTypes, but initially had this bug with my own Composite UserType. I'll attach a small test case which reproduces the mentioned issue. Full StackTrace: javax.persistence.PersistenceException: [PersistenceUnit: testunit] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at com.usertyperegistration.FooTest.setUpClass(FooTest.java:29) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: org.hibernate.MappingException: property mapping has wrong number of columns: com.usertyperegistration.Foo.bar type: org.joda.time.Interval at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:484) at org.hibernate.mapping.RootClass.validate(RootClass.java:270) at org.hibernate.cfg.Configuration.validate(Configuration.java:1324) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1786) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914) ... 21 more

    Hibernate JIRA | 3 years ago | Daniel Nuß
    javax.persistence.PersistenceException: [PersistenceUnit: testunit] Unable to build EntityManagerFactory
  3. 0

    Does Hibernate disallow read-only on @Column in embedded ID composite primary key classes (bug?)?

    Stack Overflow | 6 years ago | Kawu
    javax.persistence.PersistenceException: [PersistenceUnit: zips] Unable to build EntityManagerFactory
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Repeated column in mapping for entity: Hiv_AnswerForEntities column: variant_id (should be mapped with insert="false" update="false")

    Stack Overflow | 2 years ago
    play.api.UnexpectedException: Unexpected exception[PersistenceException: [PersistenceUnit: defaultPersistenceUnit] Unable to build EntityManagerFactory]
  6. 0

    The test case bellow used to run correclty with hibernate beta3 entitymanager beta3 and annotations beta5. After upgrading I get the following exception: javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: test.Language, for columns: [org.hibernate.mapping.Formula( langid )] at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:149) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:73) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at test.MapCollectionTestCase.testMapCollection(MapCollectionTestCase.java:12) 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 junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: org.hibernate.MappingException: Could not determine type for: test.Language, for columns: [org.hibernate.mapping.Formula( langid )] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:266) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:253) at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:68) at org.hibernate.cfg.Configuration.validate(Configuration.java:979) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1139) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:358) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:484) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:96) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:142) ... 19 more

    Hibernate JIRA | 1 decade ago | Panagiotis Korros
    javax.persistence.PersistenceException: org.hibernate.MappingException: Could not determine type for: test.Language, for columns: [org.hibernate.mapping.Formula( langid )]

  1. esaar 1 times, last 4 months ago
  2. kuldeep 16 times, last 3 months ago
  3. r1chjames 1 times, last 6 months ago
  4. Kawada 6 times, last 6 months ago
  5. Harsh 1 times, last 8 months ago
34 unregistered visitors
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 mapping has wrong number of columns: com.usertyperegistration.Foo.bar type: org.joda.time.Interval

    at org.hibernate.mapping.PersistentClass.validate()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:484)
    2. org.hibernate.mapping.RootClass.validate(RootClass.java:270)
    3. org.hibernate.cfg.Configuration.validate(Configuration.java:1324)
    4. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1786)
    4 frames
  3. Hibernate EJB
    HibernatePersistence.createEntityManagerFactory
    1. org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
    2. org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
    3. org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
    4. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:59)
    4 frames
  4. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
    2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
    2 frames
  5. com.usertyperegistration
    FooTest.setUpClass
    1. com.usertyperegistration.FooTest.setUpClass(FooTest.java:29)
    1 frame
  6. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:597)
    4 frames
  7. JUnit
    ParentRunner.run
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    4. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    5. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    6. org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    6 frames
  8. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    1 frame
  9. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    5 frames