Java Reference
In-Depth Information
private static final long serialVersionUID = 1L;
private long id;
private String firstName;
private String lastName;
private String address;
private String city;
private String state;
private String zip;
private Double longitude;
private Double latitude;
// Accessors go here
...
@Override
public String toString() {
return firstName + " " + lastName + " lives at " +
address + "," + city + " " + state + "," + zip;
}
}
The two things to note about the Customer class are that it implements the java.io.Serializable
interface so that it can be serialized and sent over the JMS queues you're using, and that you override the
toString method with something useful so you can see who is processed by what slave nodes later.
The next object to code is the RowMapper implementation that maps the data from the Customers
table in Figure 11-17 to the Customer object. Listing 11-21 shows the code for CustomerRowMapper .
Listing 11-21. CustomerRowMapper
package com.apress.springbatch.chapter11.jdbc;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;
import com.apress.springbatch.chapter11.domain.Customer;
public class CustomerRowMapper implements RowMapper<Customer> {
public Customer mapRow(ResultSet rs, int arg1) throws SQLException {
Customer cust = new Customer();
cust.setAddress(rs.getString("address"));
cust.setCity(rs.getString("city"));
cust.setFirstName(rs.getString("firstName"));
cust.setId(rs.getLong("id"));
cust.setLastName(rs.getString("lastName"));
cust.setState(rs.getString("state"));
cust.setZip(rs.getString("zip"));
cust.setLongitude(rs.getDouble(“longitude”));
cust.setLatitude(rs.getDouble(“latitude”));
 
Search WWH ::




Custom Search