Hibernate Caching Mechanism, Hibernate Cache
Every fresh session having its own cache memory, Caching is a mechanism for storing the loaded objects into a cache memory. The advantage of cache mechanism is, whenever again we want to load the same object from the database then instead of hitting the database once again, it loads from the local cache memory only, so that the no. of round trips between an application and a database server got decreased. It means caching mechanism increases the performance of the application.
In hibernate we have two levels of caching
- First Level Cache [ or ] Session Cache
- Second Level Cache [ or ] Session Factory Cache [ or ] JVM Level Cache
Let us see one by one session cache concepts in depth.