Skip to content

Commit

Permalink
Doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgbutler committed Oct 24, 2024
1 parent adc2931 commit cfb47bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class RenderingStrategy {
public static final String DEFAULT_PARAMETER_PREFIX = "parameters"; //$NON-NLS-1$

/**
* Generate a unique key that can be used to place a parameter value in the parameter map
* Generate a unique key that can be used to place a parameter value in the parameter map.
*
* @param sequence a sequence for calculating a unique value
* @return a key used to place the parameter value in the parameter map
Expand Down
30 changes: 25 additions & 5 deletions src/site/markdown/docs/springBatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ SelectStatementProvider selectStatement = SpringBatchUtility.selectForCursor(pe
.render();
```

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

1. Replace `SpringBatchUtility.selectForCursor(...)` with `SqlBuilder.select(...)`
2. Replace `render()` with `render(RenderingStrategies.MYBATIS3)`
Expand Down Expand Up @@ -114,6 +114,26 @@ Notice the following important items:
2. The query must be rendered with the `SPRING_BATCH_PAGING_ITEM_READER_RENDERING_STRATEGY` rendering strategy. This
rendering strategy will render the query so that it will respond properly to the runtime values supplied for page size
and skip rows.
3. Note the use of `SpringBatchUtility.toParameterValues(...)`. This utility will set up the parameter Map correctly for
the rendered statement, and for use with a library supplied `@selectProvider`. See the following for an example of
the mapper method used for the query coded above:

```java
@Mapper
public interface PersonMapper {

@SelectProvider(type=SpringBatchProviderAdapter.class, method="select")
@Results({
@Result(column="id", property="id", id=true),
@Result(column="first_name", property="firstName"),
@Result(column="last_name", property="lastName")
})
List<PersonRecord> selectMany(Map<String, Object> parameterValues);
}
```

Note the use of the `SpringBatchProviderAdapter` - that adapter knows how to retrieve the rendered queries from the
parameter map initialed in the method above.

### Migrating from 1.x Support for MyBatisPagingItemReader

Expand All @@ -128,9 +148,9 @@ SelectStatementProvider selectStatement = SpringBatchUtility.selectForPaging(pe
.render();
```

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

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

0 comments on commit cfb47bc

Please sign in to comment.