wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes  what is second level hibernate cache? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark " what is second level hibernate cache?" Watch " what is second level hibernate cache?" New topic
Author

what is second level hibernate cache?

Ashish bharadwaj
Greenhorn

Joined: Aug 03, 2010
Posts: 3

Hi All,

can you tell me what is second level hibernate cache
Reddy Prashanth
Ranch Hand

Joined: Aug 09, 2005
Posts: 61
Each hibernate session has an implicit cache associated with it and is valid as long as the session is open. This is called first level cache. Hibernate use this cache to store all operations and entity states so that, it will execute the sql queries as late as possible (at the flush time, by default).

Similarly, at the session factory level, we can configure a cache and it is available to all the sessions that are opened using that session factory. If configured properly, it will increase the application performance. There are various cache providers supported by hibernate for this (ehcache, jboss cache..etc). If a particular entity is not in the first level (session level) cache, then hibernate will consult the second level cache, and it will reach the DB only when the entity is not available in second level cache also. You can enable this second level cache per Entity, per collection or even per query basis (query results will be cached).

Check in hibernate reference documentation or google it. You can find many examples on how to configure second level cache.
Hope this helps you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is second level hibernate cache?
 
Similar Threads
Hibernate- why my query results are caching?
Hibernate cache and data from backend
Hibernate caching- Which caching to use for performance ?
wht is second level cache in hibernate ?
Level 2 cache enabled, query cache disabled