negative is a debit). The file ends with a single summary record containing the
number of records in the file.
After importing the transactions into a transaction table, apply them to a
separate account summary table that consists of the account number and the
current account balance.
Generate a summary file ( summary.csv ) that lists the account number and
balance for each account.
Looking at these steps from a design perspective, you want to validate that the number of records
you import matches the summary file before applying the transactions to each user's account. This
integrity check can save you many hours of recovery and reprocessing when dealing with large amounts
To start this job, let's look at the file formats and data model. The file format for this job is simple
comma-separated value (CSV) files. This lets you easily configure the appropriate readers and writers
with no code. Listing 6-22 shows example record formats for each of the two files you're using
( transaction.csv and summary.csv , respectively).
Listing 6-22. Sample Records for Each of the Two Files
For this example, you also keep the data model simple, consisting of only two tables: Transaction
and Account_Summary. Figure 6-6 shows the data model.
Figure 6-6. Transaction data model
To create the job, begin with a fresh copy of the Spring Batch shell from the zip distribution as
covered in previous chapters. With your project set up, configure batch.properties to use your MySQL
instance as you have up to now.
When the boilerplate shell is ready to go, you can configure the job. Create a new file,
transactionJob.xml , in the <PROJECT_HOME>/src/main/resources/jobs directory, and configure the job as
shown in Listing 6-23.
Listing 6-23. transactionJob.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns=" http://www.springframework.org/schema/batch"