adspace
What is the difference between first level cache and second level cache?
Answer Posted / Rohit Katarya
First-level cache (Session Cache) and Second-level cache are caching mechanisms provided by Hibernate:
1. First-level cache: It's specific to each active session and stores data retrieved from a database during the session's lifetime. The first-level cache allows subsequent queries to reuse fetched objects, improving performance.
2. Second-level cache (SessionFactory Cache): It's a global, shared cache that can store data across multiple sessions and even between different Hibernate instances. By default, Hibernate uses EhCache as the second-level cache provider.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers