In my app I am using sqlProcessor as database framework: https://github.com/hudec/sql-processor/wiki.
so when I want to read list of object I call:
List<MyClass> myClassList = myClassDao.list(...)
How should I iterate over this list in itemReader or how should I create my custom item reader which read data from database using sqlProcessor
Use an ItemReaderAdapter.
From Javadoc:Invokes a custom method on a delegate plain old Java object which itself provides an item.
<bean id="itemReader" class="org.springframework.batch.item.adapter.ItemReaderAdapter">
<property name="targetObject" ref="myClassDao" />
<property name="targetMethod" value="list" />
<property name="arguments">
<list>
<!-- add arguments list -->
</list>
</property>
</bean>
<bean id="myClassDao" class="path.to.MyClassDAO" /
If you have special condition, arguments and other needs you can create your own ItemReader, but you can extends ItemReaderAdapter
to reuse your DAO and save time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With