High-Performance Java Persistence – Chapter 16 – Caching

Part 2, Chapter 16

Every new chapter of my book is released right after it’s being completed, so the reader doesn’t have to wait for the whole part to be finished to get access to new material.

Table of content

This chapter explains how enterprise caching works, from database internal buffers, to application-level caching, and the second-level cache offered by Hibernate.

16. Caching
16.1 Caching flavors
16.2 Cache synchronization strategies
16.2.1 Cache-aside
16.2.2 Read-through
16.2.3 Write-invalidate
16.2.4 Write-through
16.2.5 Write-behind
16.3 Database caching
16.4 Application-level caching
16.4.1 Entity aggregates
16.4.2 Distributed key/value stores
16.4.3 Cache synchronization patterns
16.4.4 Synchronous updates
16.4.5 Asynchronous updates Change data capture
16.5 Second-level caching
16.5.1 Enabling the second-level cache
16.5.2 Entity cache loading flow
16.5.3 Entity cache entry Entity reference cache store
16.5.4 Collection cache entry
16.5.5 Query cache entry
16.5.6 Cache concurrency strategies READ_ONLY Inserting READ_ONLY cache entries Updating READ_ONLY cache entries Deleting READ_ONLY cache entries NONSTRICT_READ_WRITE Inserting NONSTRICT_READ_WRITE cache entries Updating NONSTRICT_READ_WRITE cache entries Risk of inconsistencies Deleting NONSTRICT_READ_WRITE cache entries READ_WRITE Inserting READ_WRITE cache entries Updating READ_WRITE cache entries Deleting READ_WRITE cache entries Soft locking concurrency control TRANSACTIONAL XA_Strict mode XA mode Inserting TRANSACTIONAL cache entries Updating TRANSACTIONAL cache entries Deleting TRANSACTIONAL cache entries
16.5.7 Query cache strategy Table space query invalidation Native SQL statement query invalidation

Continue reading “High-Performance Java Persistence – Chapter 16 – Caching”

Speedment ORM – deliberate enterprise caching

A small company with big dreams

I first heard of Speedment while watching a Hazelcast webinar about a RDBMS Change Data Capture approach for updating the in-memory data grid. Their products are very much in-line with Greg Luck’s Deliberate caching and I can see many enterprise products gaining from this new paradigm shift.

We have the pleasure of talking to Per-Åke Minborg, who is the CTO and one of the founders of Speedment AB.

Continue reading “Speedment ORM – deliberate enterprise caching”

How does Hibernate Query Cache work


Now that I covered both Entity and Collection caching, it’s time to investigate how Query Caching works.

The Query Cache is strictly related to Entities, and it draws an association between a search criterion and the Entities fulfilling that specific query filter. Like other Hibernate features, the Query Cache is not as trivial as one might think.

Continue reading “How does Hibernate Query Cache work”