Spring Batch DataReader 在读取项目集合末尾返回额外的空对象?

发布于 2024-09-03 18:47:11 字数 96 浏览 3 评论 0原文

我正在使用 Spring Batch - 使用数据读取器加载项目列表。对于我的每个读者来说,他们都在列表末尾返回一个额外的空对象。

有人见过这个吗?我做错了什么?

I'm using 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぶ宁プ宁ぶ 2024-09-10 18:47:11

这是正常行为。

读取器停在空元素上。
但要找到空元素,就必须找到它。
结果,发出了 null 元素,但它将是最后一个元素,并且不会调用 writer。

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.

谁的新欢旧爱 2024-09-10 18:47:11

听起来您正在从 ItemReader 实现 read() 方法
http://static.springsource.org/ spring-batch/apidocs/org/springframework/batch/item/ItemReader.html

你想要做的是实现 readCursor(ResultSet rs, int currentRow) 方法JdbcCursorItemTeader - 这将阻止此行为。
http://static.springsource。 org/spring-batch/apidocs/org/springframework/batch/item/database/JdbcCursorItemReader.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文