Skip to content

Commit 5a3f9a8

Browse files
committed
[ci skip] Missing docs for MyBatisCursorItemReader
1 parent e7bce39 commit 5a3f9a8

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

src/site/xdoc/batch.xml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@
2828
<body>
2929
<section name="Spring Batch">
3030
<p>
31-
As of version 1.1.0 MyBatis-Spring provides two beans for building Spring Batch applications: the <code>MyBatisPagingItemReader</code>
32-
and the <code>MyBatisBatchItemWriter</code>. Both beans and this documentation are ports of their corresponding iBATIS 2.x versions
33-
that are provided by default by in the Spring Batch bundle.
31+
As of version 1.1.0 MyBatis-Spring provides three beans for building Spring Batch applications: the <code>MyBatisPagingItemReader</code>,
32+
<code>MyBatisCursorItemReader</code> and the <code>MyBatisBatchItemWriter</code>.
3433
</p>
3534

3635
<p>
@@ -40,7 +39,7 @@
4039

4140
<subsection name="MyBatisPagingItemReader">
4241
<p>
43-
This bean is an <code>IteamReader</code> that reads records from a database using MyBatis in a paging fashion.
42+
This bean is an <code>IteamReader</code> that reads records from a database in a paging fashion.
4443
</p>
4544

4645
<p>
@@ -117,6 +116,41 @@
117116

118117
</subsection>
119118

119+
<subsection name="MyBatisCursorItemReader">
120+
<p>
121+
This bean is an <code>IteamReader</code> that reads records from a database using a cursor.
122+
</p>
123+
124+
<p>
125+
<span class="label important">NOTE</span> To use this bean you need at least MyBatis 3.4.0 or a newer version.
126+
</p>
127+
128+
<p>
129+
It executes the query specified as the <code>setQueryId</code> property to retrieve requested data
130+
by using the method <code>selectCursor()</code>.
131+
Each time a <code>read()</code> method is called it will return the next element of the cursor until no more
132+
elements are left.
133+
</p>
134+
135+
<p>
136+
The reader will use a separate connection so the select statement does no participate in any transactions created
137+
as part of the step processing.
138+
</p>
139+
140+
<p>When using the cursor you can just execute a regular query:</p>
141+
<source><![CDATA[<select id="getEmployee" resultMap="employeeBatchResult">
142+
SELECT id, name, job FROM employees ORDER BY id ASC
143+
</select>]]></source>
144+
145+
<p>Follows below a sample configuration snippet:</p>
146+
147+
<source><![CDATA[<bean id="reader" class="org.mybatis.spring.batch.MyBatisCursorItemReader">
148+
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
149+
<property name="queryId" value="getEmployee" />
150+
</bean>]]></source>
151+
152+
</subsection>
153+
120154
<subsection name="MyBatisBatchItemWriter">
121155

122156
<p>

0 commit comments

Comments
 (0)