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.  [ 1 post ] 
Author Message
 Post subject: Exception when using query cache and ResultTransformer
PostPosted: Fri Apr 09, 2010 1:46 pm 
Newbie

Joined: Fri Apr 09, 2010 1:24 pm
Posts: 3
When I try to cache a Criteria Query that is using a ResultTransformer, it causes an ClassCastException.

Sample Code:

Criteria criteria = session.createCriteria(User.class);
criteria.setProjection(Projections.projectionList().add(Projections.property("firstName")).add(Projections.property("lastName")));
criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
criteria.setCacheable(true);
criteria.list();

Exception:

java.lang.ClassCastException: java.util.HashMap cannot be cast to [Ljava.lang.Object;
at org.hibernate.cache.StandardQueryCache.put(StandardQueryCache.java:104)
at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2274)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2206)
at org.hibernate.loader.Loader.list(Loader.java:2164)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:119)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1706)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:347)

I did some research into the problem and found this bug report: http://opensource.atlassian.com/project ... e/HHH-2463. The last comment says that it should be fixed, but I am still seeing the bug in Hibernate 3.5. Does anyone know what the status of this bug is, or know what I can do to fix it? I know transforming the results after calling criteria.list() will avoid the exception, but I would rather not do that unless I have to.


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

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.