1.

What is hibernate caching?

Answer»

Hibernate caching is the strategy for improving the application performance by pooling objects in the cache so that the queries are EXECUTED faster. Hibernate caching is particularly useful when fetching the same data that is executed multiple times. Rather than hitting the database, we can just access the data from the cache. This results in REDUCED throughput time of the application.

Types of Hibernate Caching

First Level Cache:

  • This level is enabled by default.
  • The first level cache resides in the hibernate session object.
  • Since it belongs to the session object, the scope of the data stored here will not be AVAILABLE to the entire application as an application can MAKE use of multiple session objects.
First Level Caching

Second Level Cache:

  • Second level cache resides in the SessionFactory object and due to this, the data is accessible by the entire application.
  • This is not available by default. It has to be enabled explicitly.
  • EH (EASY Hibernate) Cache, Swarm Cache, OS Cache, JBoss Cache are some example cache providers.
Second Level Caching


Discussion

No Comment Found