Java Reference
In-Depth Information
if(customer == null) {
return null;
} else {
Statement statement = new Statement();
return statement;
public void setCustomerReader(ItemReader<Customer> customerReader) {
this.customerReader = customerReader;
public void setTickerDao(TickerDao tickerDao) {
this.tickerDao = tickerDao;
CustomerStatementReader begins its processing in the read method. You read in a customer from the
ItemReader you configure. If one isn't found, you consider all the input exhausted and tell Spring Batch
that by returning null . If a customer is returned, you create a new Statement object for them, including
the customer you just received as well as the associated other data, via TickerDaoJdbc .
TickerDao for this step needs two new methods: getTotalValueForCustomer , which returns a
BigDecimal value of the total value of the securities the customer currently holds, and
getStocksForCustomer , which returns a List of Transaction items representing the customer's current
stock holdings. Listing 10-43 shows the updated TickerDao with the new methods.
Listing 10-43. TickerDaoJdbc
package com.apress.springbatch.statement.dao.impl;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import com.apress.springbatch.statement.dao.TickerDao;
import com.apress.springbatch.statement.domain.Ticker;
import com.apress.springbatch.statement.domain.Transaction;
public class TickerDaoJdbc extends JdbcTemplate implements TickerDao {
private static final String FIND_BY_SYMBOL = "select * from ticker t where ticker = ?";
Search WWH ::

Custom Search