Hibernate version: 2.1
We have a custom Persister that all of our mapping files use. Everything works fine except for when we map the table per subclass inheritance mapping. Then we get the following error. If I remove the custom Persister from the mapping file, then it works fine. Is there an anything special we need to do with the Persister to get joined-subclass to work. The code for the persister is after the exception.
java.lang.ExceptionInInitializerError
at shaw.spectrum.core.persistence.HibernateTestTxBroker.beginTransaction(HibernateTestTxBroker.java:27)
at shaw.spectrum.core.account.test.ChargeOffDAOTest.setUp(ChargeOffDAOTest.java:47)
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:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.lang.RuntimeException: Exception building SessionFactory: discriminator mapping required for polymorphic persistence
at shaw.spectrum.core.persistence.HibernateAbstractSessionUtil.<clinit>(HibernateAbstractSessionUtil.java:46)
... 12 more
Caused by: net.sf.hibernate.MappingException: discriminator mapping required for polymorphic persistence
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:717)
at shaw.spectrum.core.persistence.SpectrumPersister.<init>(SpectrumPersister.java:27)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at net.sf.hibernate.persister.PersisterFactory.create(PersisterFactory.java:75)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:47)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:739)
at shaw.spectrum.core.persistence.HibernateAbstractSessionUtil.<clinit>(HibernateAbstractSessionUtil.java:37)
... 12 more
/**
* Custome Persister that exposes a public method to get the actual column name
* ,of the property/domain class this persister is associated with, using the
* "protected" method EntityPersister.getActualPropertyColumnNames.
*
* @version $Revision: 1.1 $ $Date: 2004/06/15 13:52:32 $
*
*/
public class CustomPersister extends EntityPersister {
/**
* @param model
* @param factory
* @throws net.sf.hibernate.HibernateException
*/
public CustomPersister(PersistentClass model, SessionFactoryImplementor factory)
throws HibernateException {
super(model, factory);
}
/**
* Get the String Array and return the first string (it contains
* the column name of the property refered by the index i).
* @param i
* @return
*/
public String getColumnName(int i) {
return (super.getActualPropertyColumnNames(i))[0];
}
/**
* For Component Types, return all property column names
* @param i
* @return
*/
public String[] getColumnNames(int i) {
return super.getActualPropertyColumnNames(i);
}
}
|