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
3
votes
1 answer

Second Level Cache never hits using, spring3, hibernate4, ehcache?

using versions; 3.2.8.RELEASE 4.2.11.Final hibernate configuration; ...
hevi
  • 2,432
  • 1
  • 32
  • 51
3
votes
7 answers

NHibernate 2nd lvl cache, custom query, sqldialect

I got trunk version of NH and FNH. When i try to add 2nd level cache, some parts of NHibernate forgets about chosen sqldialect. Initial configuration: var cfg = Fluently.Configure() .Database(MsSqlConfiguration.MsSql2008 …
Arnis Lapsa
  • 45,880
  • 29
  • 115
  • 195
3
votes
1 answer

Will HQL query use Hibernate second-level cache

I would like to clarify some points regarding the secondary level cache of hibernate. The point to clarify is, will the HQL queries always hit the database (at least for getting ids). Consider we have entities class Customer { long id; //…
Sanush Chacko
  • 91
  • 1
  • 8
3
votes
2 answers

How can I load everything up in nhibernate 2nd level cache?

I have an asp.net-mvc site that is using nhibernate and SQL server, there are a few pages that are quite slow because they require view that need queries which join about 25 different tables. If i don't a large join it takes a while and if I do a…
leora
  • 188,729
  • 360
  • 878
  • 1,366
3
votes
2 answers

NHibernate + ASP.NET + Open Session in View + L2Cache

I am using CodeProject's well known Open Session in View to handle NHibernate Sessions. Does it works well with Level 2 Cache? Anyone has succeeded doing it? Should I use NH.Burrow instead? Any advice on l2 cache in asp.net best practices is…
Pedro
  • 11,514
  • 5
  • 27
  • 40
3
votes
1 answer

Does Hibernate 2nd-Level cache invalidate when running a JPQL update statement

When you run a JPQL update or delete query, is Hibernate smart enough to invalidate the 2nd-level cache for the entity that is changed? Contrived example: You have the JPQL: update Product p set p.status = 'S' where p.name like 'Monitor%' If you…
larf311
  • 1,845
  • 3
  • 20
  • 24
3
votes
0 answers

Infinispan with Hibernate: Objects are not added to the cache or removed after an update

We currently have some problems with our Infinispan 2nd level cache. We've prepared two test cases: 1) Newly created objects are not put in the 2nd level Cache. We create a new object (TestEntity) in a first transaction. We see that it is not put in…
3
votes
1 answer

NHibernate query cache and WCF

I've enabled query cache for one of my queries, it works fine (query result is taken from query cache and entities from second level cache) when I run a test or a console application. However, if I run the same queries through a WCF service, the…
Meidan Alon
  • 3,074
  • 7
  • 45
  • 63
3
votes
4 answers

How do I access Hibernate statistics from an entitymanager?

I'm using Spring 3.1.1.RELEASE, JUnit 4.8.1, and Hibernate 4.1.5.Final. I'm trying to test whether my second level cache is configured correctly, but am unsure of how to do it. I'm using the JPA entity manager, configured in Spring like so…
Dave
  • 15,639
  • 133
  • 442
  • 830
3
votes
4 answers

Hibernate L2 Cache on cluster

Q1: Am I right that only this vendors support Hibernate L2 cache on cluster? Terracotta for Hibernate (comercial) SwarmCache (not released since 2003) JBoss Cache 1.x JBoss Cache 2 Q2: Are there are any alternatives to Hibernate L2 cache? (Maybe…
Yury Litvinov
  • 1,354
  • 2
  • 16
  • 24
3
votes
2 answers

Hibernate 4 with second level cache: what wrong in my understanding?

I have starting to use Hibernate 4 with second level cache. The configuration was very simple according to the documentation:
Michael
  • 10,063
  • 18
  • 65
  • 104
3
votes
1 answer

Ehcache integration with Hibernate & Spring Exception: Second-level cache is not enabled for usage

I'm using Spring 3.1 with Hibernate 4. While using Ehcache with Hibernate, getting an error like this: Second-level cache is not enabled for usage [hibernate.cache.use_second_level_cache | hibernate.cache.use_query_cache] Even I set…
talha06
  • 6,206
  • 21
  • 92
  • 147
2
votes
1 answer

Hibernate Caching Causes Performance Drop on Low Percentage of @Cacheable Entities?

I have a Java application that uses the Hibernate persistance library, with about 100 mapped classes. To try out second-level caching, I added @Cacheable to 5 of the mapped classes. This caused a standard computation task to take double the time it…
user191776
2
votes
1 answer

What's the difference between terracotta-hibernate-cache and Ehcache Distributed with Terracotta?

Is there a difference between using Ehcache as Hibernate's second-level cache provider and distributing it with Terracotta, and using terracotta-hibernate-cache and terracotta-hibernate-agent?
DeejUK
  • 12,891
  • 19
  • 89
  • 169
2
votes
1 answer

Multiple Second Level Cache Settings With One Hibernate Mapping

Supose that there multiple Java applications which share a common entity module (Entity classes + Hibernate XML mappings). Currently, the entities are not enabled for caching (no elements within the mappings). Most of the applications…
rainer198
  • 3,195
  • 2
  • 27
  • 42