Better error logging in IdentifierGeneratorFactory (Antony Stubbs)

Description

When specifying an incorrect id generator class in the hibernate mapping file, the following error messages are produced for the exception:
Caused by: java.lang.RuntimeException: Exception building SessionFactory: could not instantiate id generator
Caused by: org.hibernate.MappingException: could not instantiate id generator
Caused by: org.hibernate.MappingException: could not interpret id generator strategy:
com.x.persistence.sdfhibernate.SomeIdentityGenerator

This doesn't show which mapping it's talking about.
The patch I submitted slightly improves the message by adding the entity name:
Caused by: org.hibernate.MappingException: could not instantiate id generator for entity com.x.persistence.hibernate.EntityClass

admitedly I haven't tested it yet, because I am unable to get maven to build hibernate. but i'm working on that now (unable to download org.codehaus.mojo:antlr-maven-pluginom:2.0-SNAPSHOT)

Environment

None

Activity

Show:
Antony Stubbs
September 18, 2007, 11:10 AM

fixed params.get to params.getProperty

Antony Stubbs
September 18, 2007, 2:38 PM

Just to comment - I have now tested this patch and it works. It generated the following output:
java.lang.ExceptionInInitializerError
at com.x.tests.hibernate.BasicTankerSetupTest.beforeClass(BasicTankerSetupTest.java:16)
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:585)
at org.junit.internal.runners.ClassRoadie.runBefores(ClassRoadie.java:49)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:36)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.RuntimeException: Exception building SessionFactory: could not instantiate id generator for entity 'com.x.persistence.hibernate.Tanker'
at com.x.tests.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:20)
... 14 more
Caused by: org.hibernate.MappingException: could not instantiate id generator for entity 'com.x.persistence.hibernate.Tanker'
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:98)
at org.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:152)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:195)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.x.tests.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:18)
... 14 more
Caused by: org.hibernate.MappingException: could not interpret id generator strategy: com.x.sdfsdf.persistence.hibernate.TriggerAssignedIdentityGenerator
at org.hibernate.id.IdentifierGeneratorFactory.getIdentifierGeneratorClass(IdentifierGeneratorFactory.java:109)
at org.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:92)
... 18 more

Steve Ebersole
October 3, 2007, 4:26 AM

applied, thanks

3.2/trunk

Assignee

Steve Ebersole

Reporter

Antony Stubbs

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure