Questions tagged [second-level-cache]

Second-level-cache, as the name implies, is a layer of cache that lives between a "primary" cache and a data service/store (relational database, in most cases) to optimize read operations on the service/store. It is different from the primary cache in its lifespan (primary cache being limited to a request lifetime) and capabilities (persist to store, clustering, etc.).

Second-level-cache, as the name implies, is a layer of cache that lives between a "primary" cache and a data service/store (relational database, in most cases) to optimize read operations on the service/store. It is different from the primary cache in its lifespan (primary cache being limited to a request lifetime) and capabilities (persist to store, clustering, etc.).

Second-level-cache is a concept most often encountered in the context of object-persistence frameworks, such as Hibernate. The idea is to allow the persistence engine to maintain a copy of entities that are available in the data service/store so that queries to retrieve them can be fulfilled using a local lookup as opposed to a full roundtrip to the service/store which invariably lives in a different server, thus requiring a network operation and incurring the associated overhead and latency/performance impact.

350 questions
8
votes
1 answer

Hibernate 2nd level cache ObjectNotFoundException with a high number of concurrent transactions

We have a Java application that uses MySQL, Hibernate (3.5.1-Final) and EHcache(1.2.3) for our 2nd level cache. Our hibernate.properties isolation level is Read-committed isolation = 2 # 2-Read committed isolation…
Dougnukem
  • 14,709
  • 24
  • 89
  • 130
8
votes
1 answer

How to use second level cache for lazy loaded collections in Hibernate?

Let's say I have two entities, Employee and Skill. Every employee has a set of skills. Now when I load the skills lazily through the Employee instances the cache is not used for skills in different instances of Employee. Let's Consider the…
Chandra Sekar
  • 10,683
  • 3
  • 39
  • 54
8
votes
4 answers

How to configure second level cache in Hibernate 4.3

I have read post related with this but not get any answer working for me. I am configuring second level cache in Hibernate v4.3. And I have used MySQL 5.0 I have written following elements in hibernate.cfg.xml
Prashant Shilimkar
  • 8,402
  • 13
  • 54
  • 89
7
votes
2 answers

Hibernate second level cache and ON DELETE CASCADE in database schema

Our Java application has about 100 classes mapped to a database (SQL Server or MySQL). We are using Hibernate as our ORM (with XML mapping files). We specify FOREIGN KEY constraints in our database schema. Most of our FOREIGN KEY constraints also…
Bat Fastard
  • 73
  • 1
  • 3
7
votes
1 answer

EHCache Configuration + Spring Boot: NoCacheRegionFactoryAvailableException

I'm trying to configure Spring Boot application with second level cache based on EHCache. I'm getting this exception: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name…
6
votes
2 answers

How I can disable the second-level cache of some certain entities in Hibernate without changing annotations

I'm using Hibernate second level cache in my application, for certain business reason I can't change the entity annotation any more. In my project, apart from changing the Database from Hibernate, there exist also other native SQL that do not go…
Kewei Shang
  • 949
  • 3
  • 11
  • 27
6
votes
1 answer

EhCache + hibernate

I have the following problem: I have a query which return me 35 results and I would like to keep in second level cache: public List getAllProducts() { Session session = this.sessionfactory.getCurrentSession(); String…
danny.lesnik
  • 18,479
  • 29
  • 135
  • 200
6
votes
0 answers

SpringBoot + JPA enable second level caching for entity not working

I am using Springboot 2.1 and spring data-jpa for persistence using @RepositoryRestResource. I have enabled caching for my API calls and that works well with @Cacheable, But now I want to enable second-level cache for all my JPA entities and have…
Sushil
  • 364
  • 6
  • 22
6
votes
3 answers

A soft-locked cache entry was expired by the underlying Ehcache

Hibernate 3.3.x, ehcache 2.2.x The following error occurs, when I try to publish a lots of users in a single go. Any idea on why this would happen and how to rectify this? Is there a way to disable this cache prior to bulk loading of users, if so…
Joe
  • 14,513
  • 28
  • 82
  • 144
6
votes
1 answer

Hibernate lazy loading and Hazelcast

we are using Hazelcast as Hibernate 2nd level cache now for a while but are recognizing long delays in storing and reading data when using more than one node. We make intensive use of composed objects and @OneToMany relations, and to increase …
Andreas
  • 2,211
  • 1
  • 18
  • 36
6
votes
2 answers

Second level cache not working in Hibernate + Spring + JPA and EhCache

Let me make my understanding clear for second level cache. There is a query in base class of my web application. This query is called for almost every action (I am using Struts and this is how application is designed so can't really mess with it),…
Knu8
  • 388
  • 3
  • 17
6
votes
2 answers

Doctrine Second Level Cache w/ Redis

after investing a few days now in figuring out why my second level cache config for doctrine is not working, I hope someone might be able to support. At the moment no second level cache call result in a hit. My project is currently set up with the…
gstoert
  • 128
  • 1
  • 7
6
votes
1 answer

Hibernate 2nd Level caching doesnt seem to be working

Im currently trying to get hibernate working using the caching provider that comes with hibernate. net.sf.ehcache.hibernate.SingletonEhCacheProvider I have a default cache and a class specific cache enabled in the ecache.xml which is referenced in…
John
  • 61
  • 1
  • 3
6
votes
1 answer

How N+1 issue can be resolved by introducing second-level cache in Hibernate?

In performance section of Hibernate documentation stated that: A completely different approach to problems with N+1 selects is to use the second-level cache. I don't understand how it might resolve problem. What may be real world example and…
J.Olufsen
  • 13,415
  • 44
  • 120
  • 185
6
votes
1 answer

JPA shared cache / second level cache in WildFly

I'm using WildFly 8.1 so JPA 2.1 and Hibernate 4.3.5 I want to use JPA shared cache / second level cache in WildFly I follow the WildFly documentation:…
kwisatz
  • 1,266
  • 3
  • 16
  • 36
1 2
3
23 24