What are the different strategies for cache mapping in Hibernate?

Hibernate provides following strategies for cache mapping:

  • Read only: If an application requires caching only for read but not for write operations, then we can use this strategy. It is very simple to use and give very good performance benefit.It is also safe to use in a cluster environment.
  • Read/Write: If an application also needs caching for write operations, then we use Read/Write strategy.Read/write cache strategy should not be used if there is requirement for serializable transaction isolation level.

    If we want to use it in a cluster environment, we need to implement locking mechanism.

  • Nonstrict Read/Write: If an application only occasionally updates the data, then we can use this strategy. It cannot be used in systems with serializable transaction isolation level requirement.
  • Transactional: This strategy supports full transactional cache providers like JBoss TreeCache.
Read the full book at www.amazon.com
Posted in Hibernate, Hibernate Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

*