Skip to content

Commit e89441e

Browse files
authored
Merge pull request #355 from CodeingBoy/master
Translate explanation for MyBatisBatchItemWriter#itemToParameterConverter
2 parents a9f5895 + 3522ab2 commit e89441e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

src/site/zh/xdoc/batch.xml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
33
4-
Copyright 2010-2018 the original author or authors.
4+
Copyright 2010-2019 the original author or authors.
55
66
Licensed under the Apache License, Version 2.0 (the "License");
77
you may not use this file except in compliance with the License.
@@ -177,11 +177,15 @@ public MyBatisCursorItemReader<Employee> reader() {
177177
<subsection name="MyBatisBatchItemWriter">
178178

179179
<p>
180-
这是一个 <code>ItemWriter</code>,通过利用 <code>SqlSessionTemplate</code> 中的批量处理功能来对给定的所有记录执行多个语句。<code>SqlSessionFactory</code> 需要被配置为 <code>BATCH</code> 执行类型。
180+
这是一个 <code>ItemWriter</code>,通过利用 <code>SqlSessionTemplate</code>
181+
中的批量处理功能来对给定的所有记录执行多个语句。<code>SqlSessionFactory</code>
182+
需要被配置为 <code>BATCH</code> 执行类型。
181183
</p>
182184

183185
<p>
184-
当调用 <code>write()</code> 时,将会执行 <code>statementId</code> 属性中指定的映射语句。一般情况下,<code>write()</code> 应该在一个事务中进行调用。<br/>
186+
当调用 <code>write()</code> 时,将会执行 <code>statementId</code>
187+
属性中指定的映射语句。一般情况下,<code>write()</code>
188+
应该在一个事务中进行调用。<br/>
185189
</p>
186190

187191
<p>下面是一个配置样例:</p>
@@ -201,18 +205,19 @@ public MyBatisBatchItemWriter<User> writer() {
201205
}]]></source>
202206

203207

204-
<p><strong>Converting a item that read using ItemReader to an any parameter object:</strong></p>
208+
<p><strong>ItemReader 读取的记录转换为任意的参数对象:</strong></p>
205209

206210
<p>
207-
By default behavior, the <code>MyBatisBatchItemWriter</code> passes a item that read using <code>ItemReader</code>
208-
(or convert by <code>ItemProcessor</code>) to the MyBatis(<code>SqlSession#update()</code>) as the parameter object.
209-
If you want to customize a parameter object that passes to the MyBatis, you can realize to use the <code>itemToParameterConverter</code> option.
210-
For example using <code>itemToParameterConverter</code> option, you can passes any objects other than the item object to the MyBatis.
211-
Follows below a sample:
211+
默认情况下,<code>MyBatisBatchItemWriter</code> 会将 <code>ItemReader</code>
212+
读取的对象(或 <code>ItemProcessor</code> 转换过的对象) 以参数对象的形式传递给
213+
MyBatis(<code>SqlSession#update()</code>)。
214+
如果你想自定义传递给 MyBatis 的参数对象,可以使用 <code>itemToParameterConverter</code> 选项。
215+
使用该选项后,可以传递任意对象给 MyBatis。
216+
举个例子:
212217
</p>
213218

214219
<p>
215-
At first, you create a custom converter class (or factory method). The following sample uses a factory method.
220+
首先,创建一个自定义的转换器类(或工厂方法)。以下例子使用了工厂方法。
216221
</p>
217222

218223
<source><![CDATA[
@@ -227,7 +232,7 @@ public static <T> Converter<T, Map<String, Object>> createItemToParameterMapConv
227232
}]]></source>
228233

229234
<p>
230-
At next, you write a sql mapping.
235+
接下来,编写 SQL 映射。
231236
</p>
232237

233238
<source><![CDATA[
@@ -237,11 +242,11 @@ public static <T> Converter<T, Map<String, Object>> createItemToParameterMapConv
237242
</select>]]></source>
238243

239244
<p>
240-
At last, you configure the <code>MyBatisBatchItemWriter</code>.
245+
最后,配置 <code>MyBatisBatchItemWriter</code>
241246
</p>
242247

243248
<source><![CDATA[
244-
// Sample for Java Config
249+
// Java 配置样例
245250
@Bean
246251
public MyBatisBatchItemWriter<Person> writer() throws Exception {
247252
return new MyBatisBatchItemWriterBuilder<Person>()
@@ -252,7 +257,7 @@ public MyBatisBatchItemWriter<Person> writer() throws Exception {
252257
}]]></source>
253258

254259
<source><![CDATA[
255-
<!-- Sample for XML Config -->
260+
<!-- XML 配置样例 -->
256261
<bean id="writer" class="org.mybatis.spring.batch.MyBatisBatchItemWriter">
257262
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
258263
<property name="statementId" value="org.mybatis.spring.sample.mapper.PersonMapper.createPerson"/>

0 commit comments

Comments
 (0)