0

Hibernate is an ORM framework which allows developers to handle database from application easily. It also allows multi level caching. Which is a great feature.

I know how does it maintain first level caching. https://howtodoinjava.com/hibernate/understanding-hibernate-first-level-cache-with-example

My concern is how it maintain first level caching while I have multiple instances of same application related/transact with same database?

Zenith
  • 1,037
  • 1
  • 10
  • 21

1 Answers1

3

My concern is how it maintain first level caching while I have multiple instances of same application related/transact with same database?

Each application runs in its JVM, so will have its own Hibernate Session (used for the first level cache) and its own Hibernate second level cache.

Note that in cases of running multiple instances of a same application, you generally wonder how to share the second level cache, not the first level that is specific most of time to the current transaction.
And to get a distributed cache, you have to favor a distributed cache solution as EHCache or HazelCast that can set in front of Hibernate.

davidxxx
  • 125,838
  • 23
  • 214
  • 215