-->
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.  [ 3 posts ] 
Author Message
 Post subject: DISTINCT_ROOT_ENTITY with projections query cache problems
PostPosted: Wed Nov 08, 2006 3:18 pm 
Newbie

Joined: Fri Aug 13, 2004 7:27 pm
Posts: 6
Hello all
iam trying to execute a simple Criteria Query

the query is as follows

DetachedCriteria detachedCriteria = DetachedCriteria.forClass(MyClass.class);
detachedCriteria.add(Restrictions.lt("day", new Date()));
detachedCriteria.add(Restrictions.eq("contentType", "xyz"));
detachedCriteria.createAlias("userContent", "userContent");
detachedCriteria.setProjection(Projections.projectionList()
.add(Projections.alias(Projections.sum("count"),"sumAlias"))
.add(Projections.groupProperty("userContent"))

).addOrder(Order.desc("sumAlias"));

detachedCriteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

This query translates to the following pseudo SQL

"Select sum(count),content_id from ....group by Content_id order by sum(count)"

when i run this with the query cache off it works fine and returns me a list of content objects i.e it uses the content_id from the query and gets me a list of content items

but with the query cache turned on i get

java.lang.ClassCastException
at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:77)
at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2119)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2063)
at org.hibernate.loader.Loader.list(Loader.java:2021)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at test.hibernate.spring.DAOTester$1.doInHibernate(DAOTester.java:199)


Seems like this piece of code in the StandQueryCache
"
cacheable.add( TypeFactory.disassemble( (Object[]) result.get(i), returnTypes, null, session, null ) );"

is casting the "transformed" object to an Object[] ...
any ideas if iam doing something wrong or if this is a bug ?

Using Hib 3.1.3


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 12:42 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please take a test from the Hibernate test suite, modify it so it reproduces the problem, and upload it to JIRA. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 09, 2006 12:44 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh, and try with the latest 3.2 release before.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.