1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.batch.sample.domain.trade.internal;
17
18 import java.math.BigDecimal;
19 import java.sql.PreparedStatement;
20 import java.sql.SQLException;
21
22 import org.springframework.batch.item.database.ItemPreparedStatementSetter;
23 import org.springframework.batch.sample.domain.trade.CustomerCredit;
24
25
26
27
28
29 public class CustomerCreditUpdatePreparedStatementSetter implements ItemPreparedStatementSetter<CustomerCredit> {
30
31 public static final BigDecimal FIXED_AMOUNT = new BigDecimal(1000);
32
33 public static final String QUERY = "UPDATE CUSTOMER SET CREDIT=? WHERE ID=?";
34
35
36
37
38 public void setValues(CustomerCredit customerCredit, PreparedStatement ps) throws SQLException {
39 ps.setBigDecimal(1, customerCredit.getCredit().add(FIXED_AMOUNT));
40 ps.setLong(2, customerCredit.getId());
41 }
42
43 }