Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

what is second level hibernate cache?

 
Greenhorn
Posts: 3
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

can you tell me what is second level hibernate cache
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic