]
Diego Pires Plentz resolved HHH-2494.
-------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
ClassCastException from Subquery with Criteria created via
DetachedCriteria
---------------------------------------------------------------------------
Key: HHH-2494
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2494
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Environment: Hibernate 3.2.2, Informix 10
Reporter: Christopher Pierce
Assignee: Diego Pires Plentz
Attachments: SubqueryExpression.java.patch
If I create a DetachedCriteria object, then call "createCriteria" to on it,
then pass a Subquery to the new Criteria, I get this exception:
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)
example:
public class EntityOne {
private long entityOneID
private EntityTwo entityTwo
...
}
public class EntityTwo {
private long entityTwoID
private EntityThree entityThree
...
}
public class EntityThree {
private long entityThreeID;
private String name;
...
}
DetachedCriteria subselect = DetachedCriteria.forClass(EntityThree.class);
subselect.add(Restrictions.like("name","test",MatchMode.START)).setProjection(Projections.id());
DetachedCriteria mainselect = DetachedCriteria.forClass(EntityOne.class);
mainselect.createCriteria("entityTwo").add(Subquery.in("entityThree",subselect));
mainselect.getExecutableCriteria(session).list();
This results in the ClasCastException error.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: