Entities do not provide remote services like session beans, so they are not concerned with the load balancing logic or session replication. JBoss EJB 3.0 persistence layer is based on the Hibernate framework and, as we have learned, this framework has a complex cache mechanism, which is implemented both at Session level and at SessionFactory level.
The latter mechanism is called second-level caching. The key characteristic of the second-level cache is that it can be used across sessions. This differentiates it from the session cache, which only (as the name says) has session scope.
Hibernate provides a flexible way to define cache providers, using the property hibernate.cache.provider_class
, when dealing with a clustered solution. However, we need a provider that is able to keep the set of data synchronized across the cluster. So which provider is fit for this purpose? Well, the answer is JBoss Cache.
The configuration of the second-level cache is broken into two steps....