If there is anyone from Hibernate on this list, will you please explain
how it uses JCS.  I may have some suggestions to improve performance.  

Cheers,

Aaron

> -----Original Message-----
> From: Ryan Breidenbach [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 13, 2003 1:20 PM
> To: Turbine JCS Users List
> Subject: Re: CacheElement hashCode problem
> 
> Here is the portion of the stacktrace you are probably most interested
> in:
> 
> [ERROR] 13:13:14 org.apache.jcs.engine.control.CompositeCache.get -
> java.lang.ClassCastException
>         at net.sf.hibernate.cache.QueryKey.equals(QueryKey.java:35)
>         at java.util.Hashtable.remove(Hashtable.java:434)
>         at
>
org.apache.jcs.engine.memory.lru.LRUMemoryCache.remove(LRUMemoryCache.ja
va
> :274)
>         at
>
org.apache.jcs.engine.control.CompositeCache.remove(CompositeCache.java:
72
> 7)
>         at
>
org.apache.jcs.engine.control.CompositeCache.remove(CompositeCache.java:
69
> 0)
>         at
>
org.apache.jcs.engine.control.CompositeCache.get(CompositeCache.java:490
)
>         at
>
org.apache.jcs.engine.control.CompositeCache.get(CompositeCache.java:440
)
>         at org.apache.jcs.access.CacheAccess.get(CacheAccess.java:236)
>         at net.sf.hibernate.cache.JCSCache.get(JCSCache.java:30)
>         at net.sf.hibernate.cache.QueryCache.get(QueryCache.java:61)
>         at
> net.sf.hibernate.hql.QueryTranslator.find(QueryTranslator.java:964)
>         at
net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
> 
> 
> Here is my cache.ccf file:
> 
> jcs.default=
>
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribut
es
> jcs.default.cacheattributes.MaxObjects=100
>
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory
.l
> ru.LRUMemoryCache
> jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.default.elementattributes.IsEternal=false
> jcs.default.elementattributes.MaxLifeSeconds=15
> 
> 
> Here is a snippet of code that is using Hibernate with caching:
> 
>     public List getAllActiveContainerTypes() {
>         final String queryString =
>                 "from ContainerType containerType where
> containerType.status = 'ACTIVE'";
>         return getHibernateTemplate().executeFind(new
> HibernateCallback() {
>             public Object doInHibernate(Session session) throws
> HibernateException, SQLException {
>                 Query query = session.createQuery(queryString);
>                 query.setCacheable(true);
>                 return query.list();
>             }
>         });
>     }
> 
> 
> Here is where the QueryKey class is breaking:
> 
>       public boolean equals(Object other) {
>               QueryKey that = (QueryKey) other;
>               ...
> 
> This object passed in is a CacheElement. Where is is cast to a
QueryKey,
> the exception is thrown. I have attached the code for the entire
class,
> but I don't think it will be useful.
> 
> Thanks for the help.
> 
> Ryan
> 
> 
> Aaron Smuts wrote:
> >
> > Can you send me a stack trace also.
> >
> > > -----Original Message-----
> > > From: Ryan Breidenbach [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, November 13, 2003 11:51 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: CacheElement hashCode problem
> > >
> > > I am using JCS with Hibernate for caching, and I came across a
> > problem.
> > > When JCS encounters an object whose MaxLifeSeconds has been
exceeded,
> > I
> > > am getting a ClassCastException. This is actually being thrown by
the
> > > net.sf.hibernate.cache.QueryKey, but I think the root of the
problem
> > is
> > > the hashCode method of the CacheElement class:
> > >
> > >     public int hashCode()
> > >     {
> > >         return key.hashCode();
> > >     }
> > >
> > > Why does it do this? The problem happens when there is a QueryKey
> > object
> > > *and* and CacheElement object that wraps a QueryKey object both in
the
> > > cache (Hashtable). This doesn't seem right. Any thoughts?
> > >
> > > Ryan
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
[EMAIL PROTECTED]
> > For additional commands, e-mail: turbine-jcs-user-
> [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to