Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'read-only cache configured for mutable entity' warn displays when application start up

I'm using Spring3.2 and JPA with Hibernate4.2.1 Final

One of my entity code is like:

@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;  
    }  
} 

We want to cache this kind of entities because theirs value will never be changed. The values will be inserted to tables before application start up. These tables look like Dictionary Values Table.

My ehcache.xml is like following:

<cache name="booleanValues"   
           eternal="false" maxElementsInMemory="10000"   
           maxElementsOnDisk="1000"  
           overflowToDisk="true"   
           diskSpoolBufferSizeMB="20"   
           timeToIdleSeconds="3000"   
           timeToLiveSeconds="6000"  
           memoryStoreEvictionPolicy="LFU" />  

But every time I start up my application, the following warn shows up, is there any issue with my configuration? How to set these entities to immutable?

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] 
like image 232
Chris Avatar asked Aug 21 '13 08:08

Chris


1 Answers

Annotate your @Entity with @org.hibernate.annotations.Immutable.

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

  ...

}
like image 178
John Strickler Avatar answered Oct 30 '22 17:10

John Strickler