Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.1.2
Mapping documents:
<class name="Event" table="LOG_EVENT" lazy="true" discriminator-value="E">
<id name="id" column="ID"> <generator class="increment"/> </id>
<discriminator column="EVENT_CLASS" type="string"/>
<property name="timeStamp" not-null="false" column="TIME_STAMP"/>
<subclass name="ObjectEvent" discriminator-value="OE">
<property name="objectId" column="OBJECT_ID" not-null="true" />
<property name="objectClass" column="OBJECT_CLASS" not-null="true" type="class" />
<list name="objectChanges" table="LOG_EVENT_OBJECT_CHANGE" inverse="true" cascade="all-delete-orphan">
<key column="LOG_EVENT_ID" />
<index column="POSN" />
<one-to-many class="ObjectEventChange" />
</list>
</subclass>
</class>
<class name="ObjectEventChange" table = "LOG_EVENT_OBJECT_CHANGE" lazy="true" discriminator-value="OEC" >
<id name="id" column="ID"> <generator class="increment"/> </id>
<discriminator column="EVENT_CHANGE_CLASS" type="string" />
<subclass name="ObjectEventPropertyChange" discriminator-value="OEPC">
<property name="propertyName" column="TARGET_NAME" not-null="true" type="string" />
<property name="propertyValue" column="TARGET_VALUE" not-null="true" type="serializable" />
</subclass>
<subclass name="ObjectEventAssociationChange" discriminator-value="OEAC">
<property name="associationName" column="TARGET_NAME" not-null="true" type="string" />
<property name="associationId" column="TARGET_ID" not-null="true" type="long" />
<property name="associationClass" column="TARGET_CLASS" not-null="true" type="class" />
</subclass>
</class>
Code between sessionFactory.openSession() and session.close():
--- THROWS THE ERROR :
return session.createCriteria(ObjectEvent.class).add(Restrictions.eq("objectClass", objectClass)).add( Restrictions.eq("objectId", objectId)).list();
--- WORKS PERFECTLY :
return getTemplate().find( "FROM ObjectEvent WHERE objectClass = ? AND objectId = ?", new Object[] { objectClass,objectId} );
Full stack trace of any exception that occurs:
org.springframework.orm.hibernate3.HibernateQueryException: Unsupported discriminator type null; nested exception is org.hibernate.QueryException: Unsupported discriminator type null
org.hibernate.QueryException: Unsupported discriminator type null
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getTypedValue(CriteriaQueryTranslator.java:498)
at org.hibernate.criterion.SimpleExpression.getTypedValues(SimpleExpression.java:71)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getQueryParameters(CriteriaQueryTranslator.java:251)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1552)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at com.tomtom.cs.connect.logging.dao.EventDaoHibernate$1.doInHibernate(EventDaoHibernate.java:26)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:365)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:333)
at com.tomtom.cs.connect.logging.dao.EventDaoHibernate.getObjectHistory(EventDaoHibernate.java:23)
at com.tomtom.cs.connect.logging.EventDaoHibernateTest.testRetrieveObjectHistory(EventDaoHibernateTest.java:36)
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)
Name and version of the database you are using:
HypersonicSQL 1.8.0.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: