Sunday, February 15, 2015

Caching in JPA and Hibernate

* (it symbolises used configuration in Easy-framework)
**(It symbolises default configuration of the provider)


Secondary Cache
Hibernate Secondary Cache
Jpa Secondray Cache (*)
CacheConcurrencyStrategy


Query Cache
Hibernate Query Cache
Jpa Query Cache(*)
storeMode


CacheConcurrencyStrategy  for Secondary cache
READ_ONLY
NONSTRICT_READ_WRITE
READ_WRITE(**) (*)
Transactional
None

Store Mode for secondary cache
USE (*) (**)
BYPASS
REFRESH

Monitoring and Verification Mechanism
View from jvisualvm tool under Mbeans tab under Hibernate list with jmx value of following
SecondLevelCachePutCount
SecondLevelCacheHitCount
SecondLevelCacheMissCount
QueryCachePutCount
QueryCacheHitCount
QueryCacheMissCount

Configuration
If you want to enable query specific  caching  add following in Entity case
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY, region="com.easy.framework.model.access.AccessRulePolicy")
hints={@QueryHint(name="org.hibernate.cacheable",value="true")}

No comments:

Post a Comment