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

1

7

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] 
Reprieve answered 21/8, 2013 at 8:15 Comment(0)
E
14

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

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

  ...

}
Extensile answered 28/2, 2014 at 21:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.