小编Dog*_*izz的帖子

Hibernate二级缓存

嗨,我遇到了一些hibernate二级缓存的问题.作为缓存提供程序,我使用ehcache.

来自persistence.xml的配置的一部分

<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.EhCacheProvider" />
<property name="hibernate.cache.provider_configuration_file_resource_path" value="/ehcache.xml" />
Run Code Online (Sandbox Code Playgroud)

我使用注释配置我的实体,所以:

@Cache(region = "Kierunek", usage = CacheConcurrencyStrategy.READ_WRITE)
public class Kierunek implements Serializable {

这些注释的导入是: import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy;

我的ehcache.xml

<diskStore path="java.io.tmpdir" />

<defaultCache maxElementsInMemory="10000" eternal="false"
    timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
    diskSpoolBufferSizeMB="30" maxElementsOnDisk="10000000"
    diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
    memoryStoreEvictionPolicy="LRU" />

<cache name="Kierunek" maxElementsInMemory="1000"
    eternal="true" overflowToDisk="false" memoryStoreEvictionPolicy="LRU" />
Run Code Online (Sandbox Code Playgroud)

谁知道为什么我会得到以下错误?

WARNING: Could not find a specific ehcache configuration for cache named [persistence.unit:unitName=pz2EAR.ear/pz2EJB.jar#pz2EJB.Kierunek]; using defaults.
19:52:57,313 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=pz2EAR.ear/pz2EJB.jar#pz2EJB state=Create
java.lang.IllegalArgumentException: Cache …
Run Code Online (Sandbox Code Playgroud)

java annotations hibernate ehcache

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

annotations ×1

ehcache ×1

hibernate ×1

java ×1