You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/antora/modules/ROOT/pages/jdbc/query-methods.adoc
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -169,7 +169,18 @@ Properties that don't have a matching column in the result will not be set.
169
169
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.
170
170
Separate queries are generated for maps, lists, sets and arrays of entities.
171
171
172
+
Queries may contain SpEL expressions where bind variables are allowed.
173
+
Such a SpEL expression will get replaced with a bind variable and the variable gets bound to the result of the SpEL expression.
172
174
175
+
.Use a SpEL in a query
176
+
[source,java]
177
+
----
178
+
@Query("SELECT * FROM person WHERE id = :#{person.id}")
179
+
Person findWithSpEL(PersonRef person);
180
+
----
181
+
182
+
This can be used to access members of a parameter, as demonstrated in the example above.
183
+
For more involved use cases an `EvaluationContextExtension` can be made available in the application context, which in turn can make any object available in to the SpEL.
173
184
174
185
NOTE: Spring fully supports Java 8’s parameter name discovery based on the `-parameters` compiler flag.
175
186
By using this flag in your build as an alternative to debug information, you can omit the `@Param` annotation for named parameters.
@@ -188,6 +199,8 @@ Named queries are expected to be provided in the property file `META-INF/jdbc-na
188
199
189
200
The location of that file may be changed by setting a value to `@EnableJdbcRepositories.namedQueriesLocation`.
190
201
202
+
Named queries are handled in the same way as queries provided by annotation.
0 commit comments