Reject Limit parameter using String-based queries.
Document limitations, add test cases for derived queries. Closes #1654
This commit is contained in:
@@ -169,6 +169,9 @@ Properties that don't have a matching column in the result will not be set.
|
||||
The query is used for populating the aggregate root, embedded entities and one-to-one relationships including arrays of primitive types which get stored and loaded as SQL-array-types.
|
||||
Separate queries are generated for maps, lists, sets and arrays of entities.
|
||||
|
||||
WARNING: Note that String-based queries do not support pagination nor accept `Sort`, `PageRequest`, and `Limit` as a query parameter as for these queries the query would be required to be rewritten.
|
||||
If you want to apply limiting, please express this intent using SQL and bind the appropriate parameters to the query yourself.
|
||||
|
||||
Queries may contain SpEL expressions where bind variables are allowed.
|
||||
Such a SpEL expression will get replaced with a bind variable and the variable gets bound to the result of the SpEL expression.
|
||||
|
||||
|
||||
@@ -182,6 +182,27 @@ Therefore also fields with auditing annotations do not get updated if they don't
|
||||
|
||||
Alternatively, you can add custom modifying behavior by using the facilities described in xref:repositories/custom-implementations.adoc[Custom Implementations for Spring Data Repositories].
|
||||
|
||||
[[r2dbc.query-methods.at-query]]
|
||||
== Using `@Query`
|
||||
|
||||
The following example shows how to use `@Query` to declare a query method:
|
||||
|
||||
.Declare a query method by using @Query
|
||||
[source,java]
|
||||
----
|
||||
interface UserRepository extends ReactiveCrudRepository<User, Long> {
|
||||
|
||||
@Query("select firstName, lastName from User u where u.emailAddress = :email")
|
||||
Flux<User> findByEmailAddress(@Param("email") String email);
|
||||
}
|
||||
----
|
||||
|
||||
WARNING: Note that String-based queries do not support pagination nor accept `Sort`, `PageRequest`, and `Limit` as a query parameter as for these queries the query would be required to be rewritten.
|
||||
If you want to apply limiting, please express this intent using SQL and bind the appropriate parameters to the query yourself.
|
||||
|
||||
NOTE: Spring fully supports Java 8’s parameter name discovery based on the `-parameters` compiler flag.
|
||||
By using this flag in your build as an alternative to debug information, you can omit the `@Param` annotation for named parameters.
|
||||
|
||||
[[r2dbc.repositories.queries.spel]]
|
||||
=== Queries with SpEL Expressions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user