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]
Annotate your
@Entity
with@org.hibernate.annotations.Immutable
.