我将 Spring3.2 和 JPA 与 Hibernate4.2.1 Final 一起使用
我的实体代码之一是:
@Entity
@Table(name = "BOOLEAN_VALUES")
@Cache(region = "booleanValues", usage = CacheConcurrencyStrategy.READ_ONLY)
public class BooleanValue {
@Column(name = "NAME")
@NotEmpty
private String name;
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
}
我们想要缓存这种实体,因为它们的值永远不会改变。这些值将在应用程序启动之前插入到表中。这些表看起来像字典值表。
我的 ehcache.xml 如下所示:
<cache name="booleanValues"
eternal="false" maxElementsInMemory="10000"
maxElementsOnDisk="1000"
overflowToDisk="true"
diskSpoolBufferSizeMB="20"
timeToIdleSeconds="3000"
timeToLiveSeconds="6000"
memoryStoreEvictionPolicy="LFU" />
但是每次我启动我的应用程序时,都会出现以下警告,我的配置有什么问题吗?如何将这些实体设置为不可变?
2013-08-21 09:36:18,983 - org.hibernate.cache.ehcache.internal.strategy.EhcacheAccessStrategyFactoryImpl -2921 [localhost-startStop-1] WARN - HHH020007: read-only cache configured for mutable entity [booleanValues]