[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2494?page=c...
]
John Ericksen commented on HHH-2494:
------------------------------------
We ran into this bug as well while trying to perform a Subquery.in()
As a workaround, we performed 2 queries, but obviously we would like to integrate the
queries together.
This seems like an easy fix, or something that should be working, please fix soon!
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 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:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira