Posts

Showing posts with the label Cache

Hibernate Caching Mechanisms Explained

In this blog post, I will be explaining Hibernate caching. Caching is the ability to buffer the data retrieved from the database. So the cache stores recently used data items. So if the same items are requested, these items are then returned from the cache thus reducing the number of calls that are made to the database. This increases the performance of an application Hibernate supports 3 types of cache – First Level, Second Level, and Query Cache. First level cache The first-level cache is nothing but the session cache. It caches data in the session. This cache is automatically enabled, programmers do not need to do anything. Hibernate stores all objects in the session.  So once Hibernate associates an object with a session, it remains in the session till the session is closed. So even if we try to load the object again, a database call is not made if the object is in the session. So also, when the code updates an object, all updates are delayed until the session is committed or close...