'read-only cache configured for mutable entity' 在应用程序启动时警告显示



我正在使用Spring3.2和JPA与Hibernate 4.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] 

@org.hibernate.annotations.Immutable注释您的@Entity

@Entity  
@Immutable
@Table(name="BOOLEAN_VALUES")  
@Cache(region="booleanValues", usage=CacheConcurrencyStrategy.READ_ONLY)  
public class BooleanValue {
  ...
}

最新更新