It survives the transaction, unlike the first-level cache, and needs a provider plus per-entity opt-in.
// application.yml
spring.jpa.properties.hibernate.cache.use_second_level_cache: true
spring.jpa.properties.hibernate.cache.region.factory_class: jcache
@Entity
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
class Country { @Id String iso; String name; }
Reference data such as countries is read once per node, not once per request.
Mutable, frequently-written entities are the wrong candidates.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11