Hibernate already provides caching mechanisms called the 1st level cache persistent context. It is in the Session area , enabled by default, and cannot be disabled.
A cache provider, such as EHCache, provides other caching mechanisms, called a second-level cache . It is located in the SessionFactory area . Layer 2 cache is not enabled by default, and you must configure it.
See this one to enable EHCache in sleep mode.
source share