Hibernate version: 3.0RC1
I have a persistent class 'A' what has a component 'comp'. One of the component's properties is derived (let's call it 'derived') by specifying SQL in 'formula' attribute in mapping document.
This construction works fine if I load object of type A and access its component's derived property. E.g.
Code:
A a = (A) session.load(A.class, key);
System.out.prinln(a.getComp().getDerived());
But the problems appear when I want to set restriction on this derived property in criteria query. E.g.
Code:
Criteria c = session.createCriteria(A.class);
c.add(
Restrictions.eq("comp.derived", value)
);
c.list();
When executing criteria query, I get NullPointerException:
Code:
java.lang.NullPointerException
at org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:68)
at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:33)
at org.hibernate.persister.entity.BasicEntityPersister.toColumns(BasicEntityPersister.java:1104)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumns(CriteriaQueryTranslator.java:402)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getColumnsUsingProjection(CriteriaQueryTranslator.java:368)
at org.hibernate.criterion.SimpleExpression.toSqlString(SimpleExpression.java:42)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:313)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:92)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1228)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)
...
Is anybody run to the same problem? Or what I am missing here?
Thanks,
Rando