What Does the @Valid Annotation Do in Spring?
@Valid tells Spring to check an object against its Bean Validation constraints. See controller, nested and programmatic validation with jakarta.validation.
2,882 posts about Java: questions with answers, tutorials and articles, newest first.
@Valid tells Spring to check an object against its Bean Validation constraints. See controller, nested and programmatic validation with jakarta.validation.
Build a custom Bean Validation annotation for Spring Boot 3 using @Constraint and ConstraintValidator, with controller usage and error handling.
CascadeType lists the JPA operations that can pass from a parent entity to its relations. Learn what each value does and which to choose for each association.
JPA cascade types propagate persist, merge, remove, refresh and detach from a parent entity to its related entities. See where to use them and where not to.
@OneToOne in JPA maps a single-valued entity association. Compare the join column, shared primary key and mappedBy mappings and the SQL they produce.
@Embedded stores the fields of an @Embeddable class as columns in the owning entity's table. See examples, column overrides, records and composite keys.
@Embeddable lets you store a reusable value object, such as an address, inside the owning entity's table. See examples with @Embedded, overrides and composite keys.
Step-by-step guide to dynamic JPA queries with CriteriaBuilder: optional filters, OR groups, paging, a count query and Spring Data Specifications.
The CriteriaBuilder interface creates the queries, predicates, expressions and orderings of the JPA Criteria API. A tour of its method groups with examples.
Build type-safe dynamic JPA queries with CriteriaBuilder, CriteriaQuery, Root and Predicate, plus metamodel, aggregates and Spring Data Specifications.
A JPA entity graph sets a per-query fetch plan, so lazy associations load in one query. Learn named graphs, graph types and Spring Data JPA usage.
Write JPQL and native SQL queries with @Query in Spring Data JPA, including named parameters, paging, projections and modifying statements.
Learn how to map one-to-one, one-to-many, many-to-one and many-to-many JPA relationships with Jakarta Persistence, and avoid N+1 and lazy-loading traps.
@Entity tells a JPA provider that a class is persistent and maps to a database table. This guide covers its requirements, naming and common mistakes.
JPA has no built-in soft delete, but Hibernate offers @SoftDelete and @SQLDelete with @SQLRestriction. See working code, restore queries and common pitfalls.
@OneToMany maps a parent entity to a collection of child entities. See how mappedBy, cascading, orphan removal and fetching work with Jakarta Persistence and Hibernate 6.
A transition map for JPA entities: which EntityManager method moves an entity between new, managed, detached and removed, and which mistakes to avoid.
@CreatedDate fills a creation timestamp automatically in Spring Data entities. See how to enable auditing, choose Instant and fix fields that stay null.
See how AuditingEntityListener fills audit fields in Spring Data JPA, how to configure it, and how to add your own entity listener.
Learn how JPA entity listeners intercept persist, update, remove and load events, how to attach them to entities, and when Spring Data auditing is the simpler choice.