Using Hibernate 3.2.6, Ehcache 1.5.
I appear to have a problem where proxies retrieved via load() are being serialized into the second-level cache, corrupting it.
Code:
ERROR http-8080-17 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/].[spring] - Servlet.service() for servlet spring threw exception
org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
at citysearch.core.taxonomy.domain.Tag$$EnhancerByCGLIB$$c33d283f.equals(<generated>)
at org.apache.commons.lang.builder.EqualsBuilder.append(EqualsBuilder.java:384)
at citysearch.core.taxonomy.domain.Tag.equals(Tag.java:364)
at org.hibernate.util.EqualsHelper.equals(EqualsHelper.java:10)
at org.hibernate.type.AbstractType.isEqual(AbstractType.java:108)
at org.hibernate.engine.TypedValue.equals(TypedValue.java:51)
at java.util.AbstractMap.equals(AbstractMap.java:427)
at org.hibernate.util.EqualsHelper.equals(EqualsHelper.java:10)
at org.hibernate.cache.QueryKey.equals(QueryKey.java:70)
at java.util.HashMap.getEntry(HashMap.java:349)
at java.util.LinkedHashMap.get(LinkedHashMap.java:280)
at net.sf.ehcache.store.MemoryStore.get(MemoryStore.java:130)
at net.sf.ehcache.Cache.searchInMemoryStore(Cache.java:1172)
at net.sf.ehcache.Cache.get(Cache.java:801)
at net.sf.ehcache.hibernate.EhCache.get(EhCache.java:82)
at org.hibernate.cache.StandardQueryCache.get(StandardQueryCache.java:105)
Basically, an object is being retrieved from the second-level cache, but it's a proxy (obtained from load()), and it cannot be initialized because it was from an earlier session. This appears to be a bug, but it is hard to replicate.
Has anyone else seen this?