Hi,
I am using the AuditInfo from
http://www.hibernate.org/48.html.
Selecting specific objects by using a usertype column within the criteria throws a NPE.
How can I use usertype columns within the criteria API?
In
http://forum.hibernate.org/viewtopic.php?t=935420 everything seems okay with cirteria, but not for my example!?
Hibernate version:2.1.6
Mapping documents:
Code:
<class name="ActorImpl" table="actor" dynamic-update="false">
[...]
<property name="auditInfo" type="AuditInfoType">
<column name="updated"/>
<column name="created"/>
<column name="updated_by"/>
<column name="created_by"/>
</property>
Code between sessionFactory.openSession() and session.close():Code:
Criteria crit = hs.createCriteria(ActorImpl.class).
add(Expression.isNotNull("updated"));
crit.list();
Full stack trace of any exception that occurs:Code:
java.lang.NullPointerException
at net.sf.hibernate.persister.NormalizedEntityPersister.toColumns(NormalizedEntityPersister.java:1099)
at net.sf.hibernate.expression.AbstractCriterion.getColumns(AbstractCriterion.java:35)
at net.sf.hibernate.expression.NotNullExpression.toSqlString(NotNullExpression.java:26)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:64)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3595)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:238)
at com.ssn.acx.api.security.SessionsAndUsersTest.testCriteriaAuditSearch(SessionsAndUsersTest.java:244)
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 com.ssn.acx.ACXAbstractTestCase.runTest(ACXAbstractTestCase.java:221)
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: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)
Name and version of the database you are using:HSQLDB 1.7