I'm trying to get 2'nd level caching to work and run into some strange error-messages. An IllegalStateException is thrown saying that "Cache is not alive" for the entities I've added caching for.
I haven't been able to find any documentation about "Cache is not alive" and don't know what it means.
Please send me in the right direction.
Or point me to an example I can follow...
Setup:
In an entity class I've added the line:
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
so that my entity class looks something like:
@Entity
@Table(name = "page")
@DiscriminatorColumn(name = "page_type", discriminatorType = DiscriminatorType.STRING)
@DiscriminatorValue("PAGE")
@Indexed
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Page implements Child, java.io.Serializable{
...
}
In hibernate.cfg.xml I've setup ehcache like this:
<property name="cache.provider_class">
net.sf.ehcache.hibernate.EhCacheProvider
</property>
I've added the ehcache.xml file:
<ehcache>
<!-- Required elements -->
<diskStore path="java.io.tmpdir"/>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="true"/>
<!-- Cache settings per class -->
<cache name="com.asap.catalog.dao.Page"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="600"
overflowToDisk="true"/>
</ehcache>
Thanks
Morten
|