Hibernate.orgCommunity Documentation

Chapter 5. Architecture

5.1. Hibernate Interface to the Caching Subsystem
5.2. Single JBoss Cache Instance Architecture
5.3. Multiple JBoss Cache Instance Architecture

We've now gone through all the main concepts and the configuration details; now we'll look a bit under the covers to understand a bit more about the architectural design of the Hibernate/JBoss Cache integration. Readers can skip this chapter if they aren't interested in a look under the covers.

The rest of Hibernate interacts with the Second Level Cache subsystem via the org.hibernate.cache.RegionFactory interface. What implementation of the interface is used is determined by the value of the hibernate.cache.region.factory_class configuration property. The interface itself is straightforward:

void start(Settings settings, Properties properties) 
       throws CacheException;

void stop();

boolean isMinimalPutsEnabledByDefault();

long nextTimestamp();

EntityRegion buildEntityRegion(String regionName, 
                               Properties properties, 
                               CacheDataDescription metadata) 
            throws CacheException;

CollectionRegion buildCollectionRegion(String regionName, 
                                       Properties properties, 
                                       CacheDataDescription cdd) 
            throws CacheException;

QueryResultsRegion buildQueryResultsRegion(String regionName, 
                                           Properties properties) 
            throws CacheException;

TimestampsRegion buildTimestampsRegion(String regionName, 
                                       Properties properties) 
            throws CacheException;

Next, we'll look at the architecture of how the JBoss Cache integration implements these interfaces, first in the case where a single JBoss Cache instance is used, next in the case where multiple instances are desired.

The following diagram illustrates the key elements involved when a single JBoss Cache instance is used:

The situation when multiple JBoss Cache instances are used is very similar to the single cache case: