开发者

Spring batch datareader returns extra null object on end of collection of read items?

开发者 https://www.devze.com 2023-01-02 05:53 出处:网络
I\'m u开发者_Python百科sing Spring batch - using datareaders to load up lists of items. For each of my readers, they all return an extra null object on the end of the list.

I'm u开发者_Python百科sing Spring batch - using datareaders to load up lists of items. For each of my readers, they all return an extra null object on the end of the list.

Has anybody seen this before? What am I doing wrong?


It's the normal behavior.

A reader stops on a null element. But to find a null element, you must find it. As a consequence, the null element is issued, but it will the last one and the writer won't be called.


It sounds like you were implementing the read() method from the ItemReader http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/ItemReader.html

What you want to do is implement the readCursor(ResultSet rs, int currentRow) method from the JdbcCursorItemTeader - this will stop this behaviour. http://static.springsource.org/spring-batch/apidocs/org/springframework/batch/item/database/JdbcCursorItemReader.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号