Java Reference
In-Depth Information
In this section, you will look at the ItemProcessorAdapter and see how it lets you use existing services as
processors for your batch job items.
Let's use an example where you read in customers, use the ItemProcessor to lookup their account
executive, and pass the AccountExecutive object to the ItemWriter. Before you get into the code itself,
let's take a look at the updated data model showing the relationship between the AccountExecutive and
the Customer . Figure 8-1 shows the updated data model.
Figure 8-1. Data model for the Customer-AccountExecutive relationship
These tables will require a domain object each. While the Customer object you previously used will
work fine with the additions of the ID field and the accountExecutive reference, you will need to create a
new AccountExecutive domain object. Listing 8-13 show the code for both domain objects.
Listing 8-13. Customer and AccountExecutive Domain Objects
Customer
package com.apress.springbatch.chapter8;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
public class Customer {
private long id;
@NotNull
@Pattern(regexp="[a-zA-Z]+")
private String firstName;
@Size(min=1, max=1)
private String middleInitial;
@NotNull
@Pattern(regexp="[a-zA-Z]+")
private String lastName;
 
Search WWH ::




Custom Search