Infinispan is an easy to configure caching mechanism with hibernate.Its comes bundled with latest Jboss Application Server (JBoss 6 EAP, JBoss 7). We can also configure infinispan caching cluster independent of JBoss. Infinispan caching works very well as the L2 cache in hibernate. But Composite key entities in hibernate will not support caching in cluster environment. In the caching cluster environment, all the entities are constructed in one of the instance and replicated or distributed in all other instances. Though the composite key entities are also replicated or distributed, but not the session factories (Composite keys will have a reference to originated session factory). Hence replication of composite key entities will fail.
For a quick start in infinispan Getting Started Guide.
Caching mechanism doesn’t work with composite keys in Hibernate. We have to remove all composite keys