Interface QueryRewriter
- All Known Implementing Classes:
DelegatingQueryRewriter
,QueryRewriter.IdentityQueryRewriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback to rewrite a query and apply sorting and pagination settings that cannot be applied based on a regularly
detectable scheme.
The underlying the query is the one right before it is used for query object creation, so everything that Spring Data and tools intends to do has been done. You can customize the query to apply final changes. Rewriting can only make use of already existing contextual data. That is, adding or replacing query text or reuse of bound parameters. Query rewriting must not add additional bindable parameters as these cannot be materialized.
- Since:
- 3.0
- Author:
- Greg Turnquist, Mark Paluch
- See Also:
-
EntityManager.createQuery(java.lang.String)
EntityManager.createNativeQuery(java.lang.String)
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault String
Rewrite the assembled query with the givenPageable
.Rewrite the assembled query with the givenSort
.
-
Method Details
-
rewrite
Rewrite the assembled query with the givenSort
.WARNING: No checks are performed before the transformed query is passed to the EntityManager.
- Parameters:
query
- the assembled query.sort
- currentSort
settings provided by the method, orSort.unsorted()
} if there are none.- Returns:
- the query to be used with the
EntityManager
.
-
rewrite
Rewrite the assembled query with the givenPageable
.- Parameters:
query
- the assembled query.pageRequest
- currentPageable
settings provided by the method, orPageable.unpaged()
if not paged.- Returns:
- the query to be used with the
EntityManager
.
-