Skip to content

Commit cfb47bc

Browse files
committed
Doc updates
1 parent adc2931 commit cfb47bc

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/main/java/org/mybatis/dynamic/sql/render/RenderingStrategy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public abstract class RenderingStrategy {
3737
public static final String DEFAULT_PARAMETER_PREFIX = "parameters"; //$NON-NLS-1$
3838

3939
/**
40-
* Generate a unique key that can be used to place a parameter value in the parameter map
40+
* Generate a unique key that can be used to place a parameter value in the parameter map.
4141
*
4242
* @param sequence a sequence for calculating a unique value
4343
* @return a key used to place the parameter value in the parameter map

src/site/markdown/docs/springBatch.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ SelectStatementProvider selectStatement = SpringBatchUtility.selectForCursor(pe
7070
.render();
7171
```
7272

73-
That utility method was limited in capability. The new method allows the full capabilities of the library. To migrate,
74-
follow these steps:
73+
That utility method was limited in capability and has been removed. The new method described above allows the full
74+
capabilities of the library. To migrate, follow these steps:
7575

7676
1. Replace `SpringBatchUtility.selectForCursor(...)` with `SqlBuilder.select(...)`
7777
2. Replace `render()` with `render(RenderingStrategies.MYBATIS3)`
@@ -114,6 +114,26 @@ Notice the following important items:
114114
2. The query must be rendered with the `SPRING_BATCH_PAGING_ITEM_READER_RENDERING_STRATEGY` rendering strategy. This
115115
rendering strategy will render the query so that it will respond properly to the runtime values supplied for page size
116116
and skip rows.
117+
3. Note the use of `SpringBatchUtility.toParameterValues(...)`. This utility will set up the parameter Map correctly for
118+
the rendered statement, and for use with a library supplied `@selectProvider`. See the following for an example of
119+
the mapper method used for the query coded above:
120+
121+
```java
122+
@Mapper
123+
public interface PersonMapper {
124+
125+
@SelectProvider(type=SpringBatchProviderAdapter.class, method="select")
126+
@Results({
127+
@Result(column="id", property="id", id=true),
128+
@Result(column="first_name", property="firstName"),
129+
@Result(column="last_name", property="lastName")
130+
})
131+
List<PersonRecord> selectMany(Map<String, Object> parameterValues);
132+
}
133+
```
134+
135+
Note the use of the `SpringBatchProviderAdapter` - that adapter knows how to retrieve the rendered queries from the
136+
parameter map initialed in the method above.
117137

118138
### Migrating from 1.x Support for MyBatisPagingItemReader
119139

@@ -128,9 +148,9 @@ SelectStatementProvider selectStatement = SpringBatchUtility.selectForPaging(pe
128148
.render();
129149
```
130150

131-
That utility method was very limited in capability. It only supported limit and offset based queries - which are not
132-
supported in all databases. The new method allows the full capabilities of the library. To migrate,
133-
follow these steps:
151+
That utility method was very limited in capability and has been removed. The prior method only supported limit and
152+
offset based queries - which are not supported in all databases. The new method described above allows the full
153+
capabilities of the library to be used. To migrate, follow these steps:
134154

135155
1. Replace `SpringBatchUtility.selectForPaging(...)` with `SqlBuilder.select(...)`
136156
2. Add `limit()`, `fetchFirst()`, and `offset()` method calls as appropriate for your query and database

0 commit comments

Comments
 (0)