Hibernate is a powerful, ultra-high performance object/relational persistence and query service for Java. Hibernate lets you develop persistent objects following common Java idiom - including association, inheritance, polymorphism, composition and the Java collections framework. Extremely fine-grained, richly typed object models are possible.

Hibernate 2.1 features support for plugin cache providers and is designed to integrate with distributed caches (2.1 also implements more aggressive use of the cache). net.sf.hibernate.cache.CacheProvider is the extension point for user-defined cache integration.

Hibernate 2.1.1 or higher is required.

### hibernate.cache.provider_class

OSCache and Hibernate 2.1 integrate though OSCacheProvider. To enable OSCache in Hibernate's configuration, add the following line to hibernate.cfg.xml:

    <property name="hibernate.cache.provider_class">net.sf.hibernate.cache.OSCacheProvider</property>

The default refresh period is CacheEntry.INDEFINITE_EXPIRY. The first time a cacheable query is done, the cache has no effect on speed. On the second and successive queries, the cache will be populated and available to be hit.

NOTE: object identifiers must have well-behaved `toString()` methods.

### Configuration

To modify the refresh period, CRON expression or maximum cache capacity, add the region configuration to your oscache.properties file, as demonstrated below:

    com.mypackage.model.Customer.refresh.period = 4000
    com.mypackage.model.Customer.cron = * * 31 Feb *
    com.mypackage.model.Customer.capacity = 500

The `com.mypackage.model.Customer` is Hibernate's internal cache region, which defaults to the classname, but which can be specified in the Hibernate mapping files (region attribute of class- cache element or collection-cache element).