Javatpoint Logo

91-9990449935

 0120-4256464

Caching in Hibernate

Hibernate caching improves the performance of the application by pooling the object in the cache.

There are mainly two types of caching: first level cache and second level cache.

First Level Cache

Session object holds the first level cache data. It is enabled by default. The first level cache data will not be available to entire application. An application can use many session object.

Second Level Cache

SessionFactory object holds the second level cache data. The data stored in the second level cache will be available to entire application. But we need to enable it explicitely.

Second Level Cache implementations are provided by different vendors such as:

  • EH (Easy Hibernate) Cache
  • Swarm Cache
  • OS Cache
  • JBoss Cache