org.hibernate.MappingException: could not instantiate id generator

Hibernate JIRA | Matt Read | 1 decade ago
  1. 0

    My hibernate.reveng.xml contains the following: <table catalog="Swan" schema="InsuranceLedger" name="jouJournal"> <primary-key> <generator class="IDENTITY"></generator> </primary-key> </table> This results in the following annotations on my @Id field when generating annotated Java: @GenericGenerator(name="generator", strategy="IDENTITY", parameters = { } ) @Id @GeneratedValue(generator="generator") @Column(name="jouSID", unique=true, nullable=false, insertable=true, updatable=true) public Long getsID() { return this.sID; } Which results in the following error at runtime: org.hibernate.MappingException: could not instantiate id generator at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:97) at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:181) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at com.catlin.architecture.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:80) at com.catlin.insuranceledger.JournalTest.setUp(JournalTest.java:38) at junit.framework.TestCase.runBare(TestCase.java:125) 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 interpret id generator strategy: IDENTITY at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:108) at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:91) ... 15 more Replacing the generated annotation with the following works fine: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="jouSID", unique=true, nullable=false, insertable=true, updatable=true) public Long getsID() { return this.sID; }

    Hibernate JIRA | 1 decade ago | Matt Read
    org.hibernate.MappingException: could not instantiate id generator
  2. 0

    My hibernate.reveng.xml contains the following: <table catalog="Swan" schema="InsuranceLedger" name="jouJournal"> <primary-key> <generator class="IDENTITY"></generator> </primary-key> </table> This results in the following annotations on my @Id field when generating annotated Java: @GenericGenerator(name="generator", strategy="IDENTITY", parameters = { } ) @Id @GeneratedValue(generator="generator") @Column(name="jouSID", unique=true, nullable=false, insertable=true, updatable=true) public Long getsID() { return this.sID; } Which results in the following error at runtime: org.hibernate.MappingException: could not instantiate id generator at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:97) at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:181) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176) at com.catlin.architecture.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:80) at com.catlin.insuranceledger.JournalTest.setUp(JournalTest.java:38) at junit.framework.TestCase.runBare(TestCase.java:125) 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 interpret id generator strategy: IDENTITY at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:108) at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:91) ... 15 more Replacing the generated annotation with the following works fine: @Id @GeneratedValue(strategy=GenerationType.IDENTITY) @Column(name="jouSID", unique=true, nullable=false, insertable=true, updatable=true) public Long getsID() { return this.sID; }

    Hibernate JIRA | 1 decade ago | Matt Read
    org.hibernate.MappingException: could not instantiate id generator
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Projeto com JSF 2.1, Spring 3.1 e JPA2/Hibernate 3.6.

    Google Groups | 5 years ago | Rafael Ponte
    javax.persistence.PersistenceException: [PersistenceUnit: IssueTrackerPU] Unable to build EntityManagerFactory

    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

      could not interpret id generator strategy: IDENTITY

      at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass()
    2. Hibernate
      SimpleValue.createIdentifierGenerator
      1. org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:108)
      2. org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:91)
      3. org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
      3 frames
    3. Hibernate
      SessionFactoryImpl.<init>
      1. org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:181)
      1 frame
    4. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
      1 frame
    5. com.catlin.architecture
      HibernateUtil.<clinit>
      1. com.catlin.architecture.dao.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:80)
      1 frame
    6. com.catlin.insuranceledger
      JournalTest.setUp
      1. com.catlin.insuranceledger.JournalTest.setUp(JournalTest.java:38)
      1 frame
    7. JUnit
      TestSuite.run
      1. junit.framework.TestCase.runBare(TestCase.java:125)
      2. junit.framework.TestResult$1.protect(TestResult.java:106)
      3. junit.framework.TestResult.runProtected(TestResult.java:124)
      4. junit.framework.TestResult.run(TestResult.java:109)
      5. junit.framework.TestCase.run(TestCase.java:118)
      6. junit.framework.TestSuite.runTest(TestSuite.java:208)
      7. junit.framework.TestSuite.run(TestSuite.java:203)
      7 frames
    8. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      3 frames