Java Reference
In-Depth Information
} while(rs.next());
if(transactions.size() > 0) {
rs.previous();
}
return transactions;
}
private Customer buildCustomer(ResultSet rs) throws SQLException {
Customer customer = new Customer();
customer.setId(rs.getLong("customer_id"));
customer.setFirstName(rs.getString("firstName"));
customer.setLastName(rs.getString("lastName"));
customer.setTaxId(rs.getString("ssn"));
customer.setAddress(buildAddress(rs));
return customer;
}
private Address buildAddress(ResultSet rs)
throws SQLException {
Address address = new Address();
address.setAddress1(rs.getString("address1"));
address.setCity(rs.getString("city"));
address.setState(rs.getString("state"));
address.setZip(rs.getString("zip"));
return address;
}
}
@SuppressWarnings("unchecked")
public Account findAccountByNumber(String accountNumber) {
List<Account> accounts = query(FIND_BY_ACCOUNT_NUMBER,
new Object[] { accountNumber }, new AccountRowMapper());
if (accounts != null && accounts.size() > 0) {
return accounts.get(0);
} else {
return null;
}
}
}
The last DAO you need to implement is the ticker DAO. This one needs to provide a bit more
functionality. As you process each of the transactions in the ItemProcessor, you try to update the
Transaction object with the id of the ticker involved in the sale. However, if the ticker isn't found, you
save a new copy of it and associate the Transaction object with that new Ticker object. Because of this,
 
Search WWH ::




Custom Search