
Originally Posted by
dkaminsky
There are several ways you can handle this. e.g.
- You can hard-code a set of if/else conditions or a switch statement into your item writer's write method.
- You can use a single item writer that dispatches to different classes based on the characteristics of the item being processed.
- You can use a CompositeItemWriter that contains all of your writers and define each writer to do nothing if the item is of the incorrect type.
If these don't provide a solution, can you explain in more detail what you are trying to do?
Just come back on my batch related work, sorry for the late reply 
Maybe I expand my previous example in a bit more detail to see if this make sense.
For example, I am doing a order system, and in each day-end, I need to do something like this:
Code:
Foreach Account a in all active account {
writeAccountCashBalanceToAuditTable(a); - action1
Foreach Order o in a.todayOrders() {
a.deductBalance(o.price); - action2
writeOrderInfoInAuditFile(o); - action3
arrangeShipment(o); - action4
}
writeAccountEndingBalanceToAuditTable(a); - action5
}
in order to mimic the above flow, as per your suggestion, shall I have a item reader that will return something like this:
Account Info (begin)
Order Info for this account
Order Info for this account
:
:
Account Info (end)
and action 1-5 are 5 item writers (chained by a composite writer), which 1 will do handling when the obj instance is Account Info (begin), 2-4 work on Order Info, and 5 work on Account Info (End)?
However, what if, as a normal situation, I want to commit after each account is processed?