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: README.adoc
+27-1Lines changed: 27 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -152,6 +152,19 @@ When determining the `RowMapper` to use for a method the following steps are fol
152
152
If applicable, wrapper types like collections or `Optional` are unwrapped.
153
153
Thus, a return type of `Optional<Person>` will use the type `Person` in the steps above.
154
154
155
+
==== Modifying query
156
+
157
+
You can mark as a modifying query using the `@Modifying` on query method.
158
+
159
+
[source,java]
160
+
----
161
+
@Modifying
162
+
@Query("UPDATE DUMMYENTITY SET name = :name WHERE id = :id")
163
+
boolean updateName(@Param("id") Long id, @Param("name") String name);
164
+
----
165
+
166
+
The return types that can be specified are `void`, `int`(updated record count) and `boolean`(whether record was updated).
167
+
155
168
=== Id generation
156
169
157
170
Spring Data JDBC uses the id to identify entities, but also to determine if an entity is new or already existing in the database.
@@ -171,6 +184,15 @@ If you are not using autoincrement-columns, you can use a `BeforeSave`-listener
171
184
If you use the standard implementations of `CrudRepository` as provided by Spring Data JDBC, it will expect a certain table structure.
172
185
You can tweak that by providing a https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mapping/model/NamingStrategy.java[`NamingStrategy`] in your application context.
| The delimiter character implementation of NamingStrategy. The default delimiter is `_`(underscore), resulting in snake case. This class does not used by default.
193
+
|===
194
+
195
+
174
196
=== Events
175
197
176
198
Spring Data JDBC triggers events which will get published to any matching `ApplicationListener` in the application context.
@@ -221,7 +243,7 @@ For each operation in `CrudRepository` Spring Data JDBC will execute multiple st
221
243
If there is a https://github.com/mybatis/mybatis-3/blob/master/src/main/java/org/apache/ibatis/session/SqlSessionFactory.java[`SqlSessionFactory`] in the application context, it will be checked if it offers a statement for each step.
222
244
If one is found, that statement will be used (including its configured mapping to an entity).
223
245
224
-
The name of the statement is constructed by concatenating the fully qualified name of the entity type with `Mapper.` and a string determining the kind of statement.
246
+
By default, the name of the statement is constructed by concatenating the fully qualified name of the entity type with `Mapper.` and a string determining the kind of statement.
225
247
E.g. if an instance of `org.example.User` is to be inserted, Spring Data JDBC will look for a statement named `org.example.UserMapper.insert`.
226
248
227
249
Upon execution of the statement an instance of [`MyBatisContext`] will get passed as an argument which makes various arguments available to the statement.
@@ -293,6 +315,10 @@ Note that the type used for prefixing the statement name is the name of the aggr
293
315
`getDomainType` the type of aggregate roots to count.
294
316
|===
295
317
318
+
==== NamespaceStrategy
319
+
320
+
You can customize the namespace part of a statement name using https://github.com/spring-projects/spring-data-jdbc/blob/master/src/main/java/org/springframework/data/jdbc/mybatis/NamespaceStrategy.java[`NamespaceStrategy`].
321
+
296
322
== Features planned for the not too distant future
0 commit comments