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/site/markdown/docs/insert.md
+16-7
Original file line number
Diff line number
Diff line change
@@ -161,25 +161,34 @@ The XML element should look like this:
161
161
```
162
162
163
163
### Generated Values
164
-
MyBatis supports returning generated values from a multiple row insert statement with some limitations. The main limitation is that MyBatis does not support nested lists in parameter objects. Unfortunately, the `MultiRowInsertStatementProvider` relies on a nested List. It is likely this limitation in MyBatis will be removed at some point in the future, so stay tuned.
164
+
MyBatis supports returning generated values from a multiple row insert statement with some limitations. The main
165
+
limitation is that MyBatis does not support nested lists in parameter objects. Unfortunately, the
166
+
`MultiRowInsertStatementProvider` relies on a nested List. It is likely this limitation in MyBatis will be removed at
167
+
some point in the future, so stay tuned.
165
168
166
-
Nevertheless, you can configure a mapper that will work with the `MultiRowInsertStatementProvider` as created by this library. The main idea is to decompose the statement from the parameter map and send them as separate parameters to the MyBatis mapper. For example:
169
+
Nevertheless, you can configure a mapper that will work with the `MultiRowInsertStatementProvider` as created by this
170
+
library. The main idea is to decompose the statement from the parameter map and send them as separate parameters to the
The first method above shows the actual MyBatis mapper method. Note the use of the `@Options` annotation to specify that we expect generated values. Further note that the `keyProperty` is set to `records.fullName` - in this case, `fullName` is a property of the objects in the `records` List.
185
+
The first method above shows the actual MyBatis mapper method. Note the use of the `@Options` annotation to specify
186
+
that we expect generated values. Further, note that the `keyProperty` is set to `records.fullName` - in this case,
187
+
`fullName` is a property of the objects in the `records` List. The library supplied adapter method will simply
188
+
return the `insertStatement` as supplied in the method call. The adapter method requires that there be one, and only
189
+
one, String parameter in the method call, and it assumes that this one String parameter is the SQL insert statement.
190
+
The parameter can have any name and can be specified in any position in the method's parameter list.
191
+
The `@Param` annotation is not required for the insert statement. However, it may be specified if you so desire.
183
192
184
193
The second method above decomposes the `MultiRowInsertStatementProvider` and calls the first method.
0 commit comments