How do you create a specification for filtering data in JPA?
Build dynamic JPA filters with Spring Data Specifications: reusable predicates, allOf and anyOf, pagination, joins and the static metamodel for type safety.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Build dynamic JPA filters with Spring Data Specifications: reusable predicates, allOf and anyOf, pagination, joins and the static metamodel for type safety.
Specification represents a reusable query condition in Spring Data JPA. See how JpaSpecificationExecutor, and, or and not build dynamic, paged searches.
Build dynamic JPA queries with CriteriaBuilder using optional predicates, joins, paging and projections, with parameter binding and a type-safe metamodel.
The Criteria API builds type-safe, dynamic JPA queries from Java objects. See CriteriaBuilder, the static metamodel and Spring Data Specifications.
Keep memory flat on big tables with pagination, streaming, batched writes, DTO projections and Spring Batch jobs in Spring Boot 3.
Pass a Pageable built with PageRequest.of(page, size, Sort) to a repository method returning Page. Spring Data adds ORDER BY, LIMIT and OFFSET for you.
Use Page and Pageable in Spring Data JPA to return paginated, sorted results with total counts, and learn when Slice or keyset scrolling is a better fit.
Understand what Pageable does in Spring Data, how PageRequest, Page and Slice fit together, and how to bind it from HTTP request parameters.
Use Pageable, Page and Slice in repository methods, write count queries for joins, project columns and scroll by keyset.
Return a ResponseEntity of Resource with the right headers to serve file downloads in Spring, and protect against path traversal and oversized responses.
Compare local disk, database and S3 file storage in Spring Boot, with secure upload code, multipart limits and the AWS SDK v2.
@RequestParam binds a multipart file field to a MultipartFile parameter in Spring. Learn single and multiple uploads, limits, @RequestPart and safe handling.
MultipartFile represents an uploaded file in Spring MVC. See how to bind, validate, store and test uploads, plus the size limits and security rules that matter.
Build a safe file upload in Spring Boot 3 with MultipartFile, a storage service, a REST endpoint, a Thymeleaf form and proper size and type validation.
JSON is the default for REST APIs, but XML still has a place. Compare syntax, size, tooling and content negotiation, with a Spring Boot example.
Configure Spring MVC content negotiation with ContentNegotiationConfigurer, a format query parameter, produces conditions and a custom ContentNegotiationStrategy.
The Accept header tells a server which response formats a client can handle. Learn its syntax, q values and how servers pick a representation.
Spring picks JSON, XML or a custom format from the Accept header. Learn produces, consumes, a format parameter and custom HttpMessageConverters.
MediaType represents HTTP media types in Spring. See how it drives consumes, produces, ResponseEntity and content negotiation.
Choose a versioning scheme and wire it into Spring. Covers the built-in API versioning in Spring Framework 7 and header or media type mappings on older releases.