-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate 3.5.0-Final DetachedCriteria
PostPosted: Fri Apr 02, 2010 4:31 pm 
Newbie

Joined: Thu Jan 19, 2006 7:16 pm
Posts: 5
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-957
HHH-249

Just 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.


Top
 Profile  
 
 Post subject: Re: Hibernate 3.5.0-Final DetachedCriteria
PostPosted: Fri Apr 02, 2010 4:41 pm 
Newbie

Joined: Thu Jan 19, 2006 7:16 pm
Posts: 5
As a follow up I just tried the same query with the following statement instead of using the Subquery static call:
Code:
crit.add(Property.forName("id").in(detachedCrit));

and ran into the same stack trace.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.