Hibernate Entity Caching: Is There an @EntityCache Annotation?
Hibernate has no @EntityCache annotation. Entity caching uses @Cacheable and @Cache, and query results use the query cache.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Hibernate has no @EntityCache annotation. Entity caching uses @Cacheable and @Cache, and query results use the query cache.
Enable the second-level and query cache with JCache, define query and timestamp regions, cache the entities and mark read-heavy queries with setCacheable(true).
Hibernate's @Cache annotation switches on second-level caching for an entity or collection and sets its concurrency strategy. See setup and strategies.
Add hibernate-jcache with Ehcache 3, switch on the second-level cache and mark read-mostly entities with @Cacheable and @Cache.
hibernate.dialect tells Hibernate which SQL dialect to use. Learn how auto-detection works in Hibernate 6 and 7 and when to set it explicitly.
A Hibernate dialect controls the SQL generated for each database. See how auto-detection works in Hibernate 6 and 7, when to set it manually and how to customize it.
The Hibernate @Fetch annotation chooses how an association is loaded: join, select or subselect. See how it differs from FetchType and when it is ignored.
Use JOIN FETCH, entity graphs or Criteria fetch to load associations in one query and avoid N+1 selects. Includes pagination and MultipleBagFetchException fixes.
@DiscriminatorColumn names the column that stores each entity type in a JPA inheritance hierarchy. Learn attributes, examples and pitfalls.
Map a class hierarchy to several tables with @Inheritance JOINED or TABLE_PER_CLASS, and compare them with SINGLE_TABLE and @MappedSuperclass.
@AttributeOverride changes the column mapping of an attribute from a mapped superclass or embeddable. See working examples, repeatable use and where it does not apply.
Use AttributeConverter, embeddables, naming strategies and Hibernate extensions to control how JPA entities map to tables and columns.
Learn what the JPA @PreRemove annotation does: when it runs, how to guard deletes, why bulk deletes skip it and how to test it with examples.
The @PostLoad annotation runs a callback after an entity is loaded from the database. See examples for derived fields, listeners, limits and testing.
@PrePersist runs just before JPA persists a new entity. See how to set timestamps and defaults, share logic with entity listeners, and avoid common callback pitfalls.
Configure a WebSocket endpoint in Spring Boot with a handler and WebSocketConfigurer, or STOMP with a message broker, plus origin checks and security.
The spring-boot-starter-websocket dependency adds WebSocket and STOMP messaging to Spring Boot for chat, notifications and live updates.
Capture createdAt, updatedAt and the acting user with @EntityListeners and JPA lifecycle callbacks, with Spring Data auditing and Envers as alternatives.
Set up Spring Boot WebSocket with a STOMP broker, message handlers and a browser client, plus the origin, authentication and scaling settings production needs.
LockModeType defines how JPA locks entities: optimistic version checks or pessimistic database locks. See every value, usage with EntityManager, and common exceptions.