-->
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.  [ 6 posts ] 
Author Message
 Post subject: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Sun Aug 08, 2010 4:15 am 
Newbie

Joined: Sun Aug 08, 2010 2:43 am
Posts: 2
I get a ClassCastException when I try to do the following:
Map cacheEntries = sessionFactory.getStatistics().getSecondLevelCacheStatistics(regionName).getEntries();

Any pointers to what could be wrong here?

I am using:
Java 1.6
Hibernate 3.5.3
GWT 2.0

I get the same exception when I use EhCache as well. However, I was expecting Hashtable cache to work.

My second level cache config is
<!-- second-level cache related properties -->
<property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.use_structured_entries">true</property>
<property name="hibernate.cache.use_query_cache">true</property>

The stack trace of the exception
Caused by: java.lang.ClassCastException: org.hibernate.cache.QueryKey cannot be cast to org.hibernate.cache.CacheKey
at org.hibernate.stat.ConcurrentSecondLevelCacheStatisticsImpl.getEntries(ConcurrentSecondLevelCacheStatisticsImpl.java:57)
at xx.server.util.HibernateUtil.printCacheStatistics(HibernateUtil.java:68)
at xx.server.staff.ManageStaffServiceImpl.searchStaff(ManageStaffServiceImpl.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562)
... 22 more


Top
 Profile  
 
 Post subject: Re: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Mon Aug 09, 2010 2:10 am 
Regular
Regular

Joined: Fri Aug 06, 2010 1:49 am
Posts: 102
Location: shynate26@gmail.com
Hi sunesh,

This is a problem in Querykey.java in hibernate. Try to decompile the file from hibernate.jar & replace the file checking the instance of check before getting the values.

Visit here for more information.

http://opensource.atlassian.com/project ... e/HHH-2021

_________________

Cheers!
Shynate
mailto:shynate26@gmail.com
www.CSSCORP.com


Top
 Profile  
 
 Post subject: Re: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Mon Aug 09, 2010 2:36 am 
Newbie

Joined: Sun Aug 08, 2010 2:43 am
Posts: 2
Thanks.

I was aware of the bug, but my understanding was that it was resolved in Hibernate 3.3, and I am using version 3.5.


Top
 Profile  
 
 Post subject: Re: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Tue Oct 12, 2010 2:49 am 
Newbie

Joined: Wed Sep 22, 2010 6:27 am
Posts: 3
Hi Sunesh,
I am facing the same problem. Whther did you find solution for avioding this exception.

java.lang.ClassCastException: org.hibernate.cache.QueryKey cannot be cast to org.hibernate.cache.CacheKey
at org.hibernate.stat.SecondLevelCacheStatistics.getEntries(SecondLevelCacheStatistics.java:74)
at com.adenyo.app.adserver.controllers.CacheManagerController.manageCache(CacheManagerController.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:167)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:414)
at

Please let me know if you have a solution. Or whether you had applied any patch.

My hibernate version is
3.3.2.GA


Top
 Profile  
 
 Post subject: Re: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Fri Aug 04, 2017 5:49 am 
Newbie

Joined: Fri Aug 04, 2017 5:44 am
Posts: 1
I am facing same issue in hibernate ver 4.1.4

Is there any workaround or fix to this issue?


Top
 Profile  
 
 Post subject: Re: ClassCastException: QueryKey cannot be cast to CacheKey
PostPosted: Tue Aug 15, 2017 7:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1630
Location: Romania
Hibernate 4.x is no longer under development. You need to try it with 5.2 as the bug might have been fixed a very long time ago.


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