0
我的配置如下JPA Hibernate和2級高速緩存
persitence.xml
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.SingletonEhCacheProvider"/>
<property name="hibernate.ejb.classcache.demo.entities.UserID" value="read-only"/>
<property name="javax.persistence.sharedCache.mode" value="ALL"/>
ehcache.xml中
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false">
<diskStore path="java.io.tmpdir/Customer-portlet-cache"/>
<defaultCache eternal="false" maxElementsInMemory="1000"
overflowToDisk="false" diskPersistent="false" timeToIdleSeconds="0"
timeToLiveSeconds="600" memoryStoreEvictionPolicy="LRU"/>
<cache name="userCache" eternal="true"
maxElementsInMemory="999" overflowToDisk="true"
diskPersistent="true" timeToIdleSeconds="0"
timeToLiveSeconds="300" memoryStoreEvictionPolicy="LRU"/>
</ehcache>
我有一個Seam組件的註解@Create它獲取所有UserID的列表並將它們存儲到緩存中。這裏的想法是讓應用程序擁有一個溫暖的緩存,但是當我從應用程序訪問實體時,我開始全面獲取Lazy初始化異常(因爲實體不與persistenceContext關聯,並且具有一些OneToMany和ManyToMany關係,並且它們不會與實體一起加載,如果我將fetchtype設置爲渴望,我會到更加討厭的區域)
當用戶訪問應用程序時,有沒有一種方法或解決方法可以獲得熱緩存。
是的singletonehcachefactory需要修復。 thatnks for that :-) – user10398 2011-04-29 07:59:28