[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2216) ClassCastException in SecondLevelCacheStatistics for cached Query
Matt McGill (JIRA)
noreply at atlassian.com
Mon Nov 6 09:35:04 EST 2006
ClassCastException in SecondLevelCacheStatistics for cached Query
-----------------------------------------------------------------
Key: HHH-2216
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2216
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: Hibernate 3.0.5
Reporter: Matt McGill
The following code in SecondLevelCacheStatistics.java produces a CCE when a Query has been cached, because of cast to CacheKey:
public Map getEntries() {
Map map = new HashMap();
Iterator iter = cache.toMap().entrySet().iterator();
while ( iter.hasNext() ) {
Map.Entry me = (Map.Entry) iter.next();
map.put( ( (CacheKey) me.getKey() ).getKey(), me.getValue() );
}
return map;
}
To reproduce, turn on query caching and execute cachable query:
session.createQuery("from Foo")
.setCacheable(true)
.setCacheRegion("fooQuery")
.list()
Then get entities in second level cache for the query region via statistics API:
sessionFactory
.getStatistics()
.getSecondLevelCacheStatistics("fooQuery")
.getEntities()
Relevent portion of example stack trace:
java.lang.ClassCastException: org.hibernate.cache.QueryKey
at org.hibernate.stat.SecondLevelCacheStatistics.getEntries(SecondLevelCacheStatistics.java:50)
at edu.taylor.domain.person.CachingPersonDirectory.logSecondLevelCacheContents(CachingPersonDirectory.java:22)
at edu.taylor.domain.person.CachingPersonDirectory.getPersonWithBannerId(CachingPersonDirectory.java:30)
Not sure whether 'major' is the right priority here. It's 'major' in the sense that it's a big hairy runtime crash, but it's not all /that/ important to me to log the contents of the 2nd level cache. Not hard to fix, in any event.
--
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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list