Cache configuration "Persistence.xml

The second level cache can be configured in general (switched on and off) via the "Persistence.xml".
image not found

Set configuration file

<property name="hibernate.javax.cache.uri" value="classpath:ehcache.xml" />

Defines over which data, with which name the cache behavior is generally configured. Normally no change necessary.

Set region factory

<property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.jcache.JCacheRegionFactory" />

Defines which RegionFactory should be used. Normally no change necessary.

Switch on caching in general

<property name="hibernate.cache.use_second_level_cache" value="true" />

Turns on the caching, the second level caching basically. Does not mean that something is already cached.

Setting the strategy for turning on the cache.

<property name="javax.persistence.sharedCache.mode" value="ENABLE_SELECTIVE" />

Specifies whether all entities are cached in principle and unwanted caches must be disabled manually. Possible values:

  • value="ENABLE_SELECTIVE" → Caching off for all entities, cache must be enabled manually for each entity.

  • value="DISABLE_SELECTIVE" → Caching on for all entities, cache must be disabled manually for each entity.

Power on query cache general

<property name="hibernate.cache.use_query_cache" value="true" />

Basically turns on caching for queries. Does not mean that anything is already cached.

Setting the strategy for the two default queries "AutoQueryData" and "FindAll ".

<property name="xdev.queryCache.mode" value="ENABLE_SELECTIVE" />

Determines whether the two default queries "AutoQueryData" and "FindAll" are cached. Possible values:

  • value="ENABLE_SELECTIVE" → Caching for both queries in the entity off, cache must be enabled manually for each query.

  • value="DISABLE_SELECTIVE" → Caching for both queries in the entity on, cache must be disabled manually for each query.

  • value="ALL" → caching is switched on for both default queries of the entities unchangeably

  • value="NONE" → Caching is unchangeably switched off for the two default queries of the entities.