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.

  • 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
    via by Panagiotis Korros,
  • Currently it is impossible to declare the usage of a CompositeUserType in conjunction with an IdentifierGenerator using JSR220/Hibernate annotations - example: @Id(...) @org.hibernate.annotations.GenericGenerator(...) @org.hibernate.annotations.Type(...) @org.hibernate.annotations.Columns For further reference see attached example. Pure hibernate based version works. Using EntityManager fails with 2005-11-09 15:31:43,431 [DEBUG] [main] [AnnotationConfiguration] Process annotated classes 2005-11-09 15:31:43,435 [DEBUG] [main] [AnnotationConfiguration] processing manytoone fk mappings 2005-11-09 15:31:43,439 [INFO] [main] [Configuration] processing extends queue 2005-11-09 15:31:43,442 [INFO] [main] [Configuration] processing collection mappings 2005-11-09 15:31:43,444 [INFO] [main] [Configuration] processing association property references 2005-11-09 15:31:43,448 [INFO] [main] [Configuration] processing foreign key constraints javax.persistence.PersistenceException: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType 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 foo.bar.SimpleEntityManagerTest.setUp(SimpleEntityManagerTest.java:27) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31) Caused by: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType at org.hibernate.mapping.RootClass.validate(RootClass.java:194) at org.hibernate.cfg.Configuration.validate(Configuration.java:975) 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) ... 17 more ---------------------------- Regarding attached example: Directory pojo contains the entity related files including annotations Directory hibernate contains a junit test using pure hibernate (and HSQL) which does work. Directory jsr220 contains a junit test using EntityManager which fails.
    via by Jens Schumann,
  • 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
    via by Daniel Nuß,
  • 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
    via by Panagiotis Korros,
  • 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
    via by Daniel Nuß,
  • Currently it is impossible to declare the usage of a CompositeUserType in conjunction with an IdentifierGenerator using JSR220/Hibernate annotations - example: @Id(...) @org.hibernate.annotations.GenericGenerator(...) @org.hibernate.annotations.Type(...) @org.hibernate.annotations.Columns For further reference see attached example. Pure hibernate based version works. Using EntityManager fails with 2005-11-09 15:31:43,431 [DEBUG] [main] [AnnotationConfiguration] Process annotated classes 2005-11-09 15:31:43,435 [DEBUG] [main] [AnnotationConfiguration] processing manytoone fk mappings 2005-11-09 15:31:43,439 [INFO] [main] [Configuration] processing extends queue 2005-11-09 15:31:43,442 [INFO] [main] [Configuration] processing collection mappings 2005-11-09 15:31:43,444 [INFO] [main] [Configuration] processing association property references 2005-11-09 15:31:43,448 [INFO] [main] [Configuration] processing foreign key constraints javax.persistence.PersistenceException: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType 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 foo.bar.SimpleEntityManagerTest.setUp(SimpleEntityManagerTest.java:27) at com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31) Caused by: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType at org.hibernate.mapping.RootClass.validate(RootClass.java:194) at org.hibernate.cfg.Configuration.validate(Configuration.java:975) 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) ... 17 more ---------------------------- Regarding attached example: Directory pojo contains the entity related files including annotations Directory hibernate contains a junit test using pure hibernate (and HSQL) which does work. Directory jsr220 contains a junit test using EntityManager which fails.
    via by Jens Schumann,
    • javax.persistence.PersistenceException: [PersistenceUnit: Demo] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:916) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:887) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at ModifyArtistClient.main(ModifyArtistClient.java:8) Caused by: org.hibernate.MappingException: Could not instantiate id generator [entity-name=Song] at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:124) at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:190) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:305) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1723) at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:76) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:907) ... 5 more Caused by: org.hibernate.MappingException: org.hibernate.dialect.MySQLDialect does not support sequences at org.hibernate.dialect.Dialect.getSequenceNextValString(Dialect.java:789) at org.hibernate.id.SequenceGenerator.configure(SequenceGenerator.java:99) at org.hibernate.id.SequenceHiLoGenerator.configure(SequenceHiLoGenerator.java:58) at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.createIdentifierGenerator(DefaultIdentifierGeneratorFactory.java:118) ... 10 more

    Users with the same issue

    esaaresaar
    1 times, last one,
    nasimknasimk
    4 times, last one,
    kuldeepkuldeep
    16 times, last one,
    Unknown visitor
    Unknown visitor2 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    36 more bugmates