javax.persistence.PersistenceException: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType

Hibernate JIRA | Jens Schumann | 1 decade ago
  1. 0

    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.

    Hibernate JIRA | 1 decade ago | Jens Schumann
    javax.persistence.PersistenceException: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType
  2. 0

    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.

    Hibernate JIRA | 1 decade ago | Jens Schumann
    javax.persistence.PersistenceException: org.hibernate.MappingException: identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType
  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

    identifier mapping has wrong number of columns: foo.bar.MyObject type: foo.bar.MyCompositeType

    at org.hibernate.mapping.RootClass.validate()
  2. Hibernate
    Configuration.buildSessionFactory
    1. org.hibernate.mapping.RootClass.validate(RootClass.java:194)
    2. org.hibernate.cfg.Configuration.validate(Configuration.java:975)
    3. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1139)
    3 frames
  3. Hibernate EJB
    HibernatePersistence.createEntityManagerFactory
    1. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:358)
    2. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:484)
    3. org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:96)
    4. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:142)
    5. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:149)
    6. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:73)
    6 frames
  4. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
    2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
    2 frames
  5. foo.bar
    SimpleEntityManagerTest.setUp
    1. foo.bar.SimpleEntityManagerTest.setUp(SimpleEntityManagerTest.java:27)
    1 frame
  6. com.intellij.rt
    JUnitStarter.main
    1. com.intellij.rt.execution.junit2.JUnitStarter.main(JUnitStarter.java:31)
    1 frame