Introduction
Hibernate is a powerful object-relational mapping API. Hibernate supports several level of caching: Session, Level-2 (L2) and Query. The Session cache is a short-term cache that holds data for access within a single transaction. That is why the Session cache is always local. The L2 cache is used for storing frequently-accessed data. The Query cache holds results of queries executed by Hibernate. Cacheonix provides a Hibernate plugin that allows increasing performance of applications based on Hibernate by distributing Hibernate's L2 and Query caches. For more information on caching in Hibernate please see Hibernate documentation.
Configuring Cacheonix Cache Provider
To enable Cacheonix as a cache provider for Hibernate, set or the configuration property hibernate.cache.provider_class. This property is configured in hibernate.properties or hibernate.cfg.xml, depending on whether you selected a property file or an XML file for configuring Hibernate.
hibernate.properties
hibernate.cache.provider_class=cacheonix.plugin.hibernate.v32.CacheonixCacheProvider
hibernate.cfg.xml
<property name="hibernate.cache.provider_class">cacheonix.plugin.hibernate.v32.CacheonixCacheProvider</property>
For Cacheonix cache provider to work, cacheonix.jar should be added to the application classpath.
Setting Lock Timeout
Cacheonix provides a configuration property cacheonix.lock.timeout.secs that defines how long Cacheonix should wait to obtain a lock. If cacheonix.lock.timeout.secs is not set, Cacheonix uses a default value of 60 seconds.
hibernate.properties
cacheonix.lock.timeout.secs=120
hibernate.cfg.xml
<property name="cacheonix.lock.timeout.secs">120</property>
