Today I attempted an upgrade of Hibernate to 3.5.0-Final from 3.2.6.ga. Surprising to me I noticed that my Criteria based (including DetachedCriteria) unit tests were failing against my embedded database. Taking a closer look I got the following stack trace:
Code:
java.lang.ClassCastException: org.hibernate.impl.CriteriaImpl$Subcriteria cannot be cast to org.hibernate.impl.CriteriaImpl
at org.hibernate.criterion.SubqueryExpression.toSqlString(SubqueryExpression.java:43)
at org.hibernate.loader.criteria.CriteriaQueryTranslator.getWhereCondition(CriteriaQueryTranslator.java:334)
at org.hibernate.loader.criteria.CriteriaJoinWalker.<init>(CriteriaJoinWalker.java:82)
at org.hibernate.loader.criteria.CriteriaLoader.<init>(CriteriaLoader.java:67)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1550)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
Which is one I am familiar with. I thought this bug (casting DetachedCriteria to CriteriaImpl) was resolved in the following Issues:
HHH-957HHH-249Just to be complete here's an example query I am trying to execute:
Code:
Criteria crit = session.createCriteria(Mainclass.class);
DetachedCriteria detachedCrit = DetachedCriteria.forClass(Subclass.class);
detachedCrit.setProjection(Projections.groupProperty("id"));
crit.add(Subqueries.propertyIn("id", detachedCrit));
crit.list();
Is this bug back? Or is the Subqueries class depreciated? I noted on the hibernate documentation that the Property class was used instead for subquery work.
Thank you in advance for your help.