@Override public void beforeCommit(boolean readOnly) { List<T> items = (List<T>) TransactionSynchronizationManager.getResource(bufferKey); if(!CollectionUtils.isEmpty(items)) { if(!readOnly) { doWrite(items); } } }
/** * If a transaction is active, buffer items to be written just before commit. * Otherwise write items using the provided template. * * @see org.springframework.batch.item.ItemWriter#write(List) */ @Override public void write(List<? extends T> items) throws Exception { if(!transactionActive()) { doWrite(items); return; } List<T> bufferedItems = getCurrentBuffer(); bufferedItems.addAll(items); }
@Override public void beforeCommit(boolean readOnly) { List<T> items = (List<T>) TransactionSynchronizationManager.getResource(bufferKey); if(!CollectionUtils.isEmpty(items)) { if(!readOnly) { doWrite(items); } } }
/** * If a transaction is active, buffer items to be written just before commit. * Otherwise write items using the provided template. * * @see org.springframework.batch.item.ItemWriter#write(List) */ @Override public void write(List<? extends T> items) throws Exception { if(!transactionActive()) { doWrite(items); return; } List<T> bufferedItems = getCurrentBuffer(); bufferedItems.addAll(items); }