The invalidation cache is tailored to be used for Hibernate second-level caching, where you have DB (authoritative source) and Infinispan cache (with expiration, eviction, some data are not loaded from the DB yet etc.) Infinispan cache should always provide same data as those stored in DB, or don't provide the entity at all.
So you have several caching nodes, all connected to single DB. Each node can load the data from DB and cache it locally - the same entity, with the same key. However, when (possibly third) node updates/deletes the entry from DB, the caches on other nodes should not provide the cached value anymore, therefore, they need to get to know that the locally-cached entity should be removed. And that's what the invalidation cache does.
If you're to use second-level caching in your app, I'd strongly recommend trying Hibernate 5 (5.0.0.Final was publicly released week ago). There are few flaws in Hibernate 4.x implementation that can make the cache provide results inconsistent with DB (stale data). I think that some fixed did not make it to 5.0.0.Final (will get to 5.0.1) but upgrading micro version is easy as soon as that's out.
thanks for your reply. Just one clarification, the "hibernate" invalidation cache is independent from the second-level cache ? I mean you need to activate the 2LC on the applicaiton server in order to have the invalidation + local query + timestamp caches working ?
The application server already has an active 2nd Level cache. You only need to activate it inside of the persistence.xml in your application.
If you use hibernate direct ou need to configure it there in this case the server-cacheis not used.
I don't fully understand the question, but there are two things: Infinispan invalidation-mode cache (which is just one way how the cache may operate), and then there's the pluggable second-level cache support in Hibernate ORM. One implementation of this (hibernate-infinispan module) integrates Infinispan, and (as an implementation detail) uses invalidation-mode cache for entities.