Hello!!
Thanks to be here.
I would like to show a brief configuration inside persistence.xml to enable the second level cache over JBoss EAP 6.x, 7 or Wildfly 8.x, 9.
The second level cache is based on Infinispan framework.
First of all, edit the persistence.xml file.
<!-- Caching is enabled for all entities for Cacheable(true) is specified -->
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<!-- shared-cache-mode>ALL</shared-cache-mode -->
<properties>
<property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
<property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
<property name="hibernate.jdbc.batch_versioned_data" value="true"/>
<property name="hibernate.generate_statistics" value="false" />
<property name="hibernate.jdbc.use_streams_for_binary" value="true" />
<!-- second level cache with infinispan -->
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.region.factory_class" value="org.jboss.as.jpa.hibernate4.infinispan.InfinispanRegionFactory"/>
<property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/container/hibernate"/>
<property name="hibernate.cache.inifinispan.statistics" value="true"/>
<property name="hibernate.cache.use_minimal_puts" value="true"/>
<property name="hibernate.cache.infinispan.use_synchronization" value="false"/>
<property name="hibernate.cache.infinispan.entity.eviction.strategy" value="LIRS"/>
<property name="hibernate.cache.infinispan.entity.eviction.wake_up_interval" value="3000"/>
<property name="hibernate.cache.infinispan.entity.eviction.max_entries" value="12000"/>
<property name="hibernate.cache.infinispan.entity.expiration.lifespan" value="60000"/>
<property name="hibernate.cache.infinispan.entity.expiration.max_idle" value="40000"/>
</properties>
After that, just enable entity classes (hibernate implementation):
@Cacheable(true)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
That's it.
Thanks a lot and regards.
Most of the points are very interesting to read. Its help to my research also. Thankyou.
ReplyDeleteHibernate Training in Chennai
Spring Hibernate Training in Chennai
Hibernate Training in Velachery
Spring Training in Chennai
Spring framework Training in Chennai
Struts Training in Chennai
Wordpress Training in Chennai