How do you implement SQL dialects in Hibernate?
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.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
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.
Use LockModeType.PESSIMISTIC_WRITE with EntityManager or Spring Data @Lock, set timeouts, avoid deadlocks and handle lock failures.
@OptimisticLocking is a Hibernate annotation that sets how concurrent updates are detected. Learn its types, how it differs from JPA @Version and how to handle conflicts.
Add a @Version field, send it with each update and handle OptimisticLockingFailureException to prevent lost updates in JPA.
The JPA orphanRemoval attribute deletes a child when it is removed from its parent. Compare it with cascade REMOVE and avoid common Hibernate errors.
JPA has no update cascade type. Use CascadeType.MERGE for detached graphs and dirty checking for managed entities, as shown in this practical guide.