OPEN - issue BATCH-1401: All inserts of JobId should be of Types.BIGINT

Fixed samples to work with MySQL (except customer filter job)
This commit is contained in:
dsyer
2009-09-16 11:44:49 +00:00
parent bade1c74c5
commit d31702c20b
14 changed files with 22 additions and 29 deletions

View File

@@ -28,7 +28,7 @@ import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
public class JdbcPlayerDao extends SimpleJdbcDaoSupport implements PlayerDao {
public static final String INSERT_PLAYER =
"INSERT into players(player_id, last_name, first_name, pos, year_of_birth, year_drafted)" +
"INSERT into PLAYERS (player_id, last_name, first_name, pos, year_of_birth, year_drafted)" +
" values (:id, :lastName, :firstName, :position, :birthYear, :debutYear)";
public void savePlayer(Player player) {

View File

@@ -32,7 +32,7 @@ import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
*/
public class JdbcCustomerDebitDao implements CustomerDebitDao {
private static final String UPDATE_CREDIT = "UPDATE customer SET credit= credit-? WHERE name=?";
private static final String UPDATE_CREDIT = "UPDATE CUSTOMER SET credit= credit-? WHERE name=?";
private SimpleJdbcOperations simpleJdbcTemplate;

View File

@@ -36,7 +36,7 @@ public class JdbcTradeDao implements TradeDao {
/**
* template for inserting a row
*/
private static final String INSERT_TRADE_RECORD = "INSERT INTO trade (id, version, isin, quantity, price, customer) VALUES (?, 0, ?, ? ,?, ?)";
private static final String INSERT_TRADE_RECORD = "INSERT INTO TRADE (id, version, isin, quantity, price, customer) VALUES (?, 0, ?, ? ,?, ?)";
/**
* handles the processing of sql query

View File

@@ -76,16 +76,6 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean {
DataSourceInitializer.class.getSimpleName() + "-context.xml"));
}
/**
* @throws Throwable
* @see java.lang.Object#finalize()
*/
protected void finalize() throws Throwable {
super.finalize();
initialized = false;
logger.debug("finalize called");
}
public void destroy() {
if (destroyScripts==null) return;
for (int i = 0; i < destroyScripts.length; i++) {
@@ -102,6 +92,7 @@ public class DataSourceInitializer implements InitializingBean, DisposableBean {
}
}
}
initialized = false;
}
public void afterPropertiesSet() throws Exception {

View File

@@ -9,6 +9,7 @@ batch.jndi.name=
batch.naming.factory.initial=
batch.naming.provider.url=
batch.schema.script=schema-mysql.sql
batch.drop.script=schema-drop-mysql.sql
batch.business.schema.script=business-schema-mysql.sql
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler

View File

@@ -85,12 +85,12 @@
</property>
<property name="sql">
<value>
SELECT games.player_id, games.year_no, SUM(COMPLETES),
SELECT GAMES.player_id, GAMES.year_no, SUM(COMPLETES),
SUM(ATTEMPTS), SUM(PASSING_YARDS), SUM(PASSING_TD),
SUM(INTERCEPTIONS), SUM(RUSHES), SUM(RUSH_YARDS),
SUM(RECEPTIONS), SUM(RECEPTIONS_YARDS), SUM(TOTAL_TD)
from games, players where players.player_id =
games.player_id group by games.player_id, games.year_no
from GAMES, PLAYERS where PLAYERS.player_id =
GAMES.player_id group by GAMES.player_id, GAMES.year_no
</value>
</property>
</bean>

View File

@@ -24,7 +24,7 @@
<property name="itemSqlParameterSourceProvider">
<bean class="org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider" />
</property>
<property name="sql" value="UPDATE customer set credit = :credit where id = :id" />
<property name="sql" value="UPDATE CUSTOMER set credit = :credit where id = :id" />
<property name="dataSource" ref="dataSource" />
</bean>

View File

@@ -54,7 +54,7 @@
class="org.springframework.batch.item.database.BeanPropertyItemSqlParameterSourceProvider" />
</property>
<property name="sql"
value="UPDATE customer set credit = :credit where id = :id" />
value="UPDATE CUSTOMER set credit = :credit where id = :id" />
<property name="dataSource" ref="dataSource" />
</bean>

View File

@@ -55,7 +55,7 @@
<bean id="customerSqlItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="SELECT id, name, credit FROM customer " />
<property name="sql" value="SELECT id, name, credit FROM CUSTOMER " />
<property name="rowMapper">
<bean class="org.springframework.batch.sample.domain.trade.internal.CustomerCreditRowMapper" />
</property>

View File

@@ -35,12 +35,12 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
private static final BigDecimal CREDIT_INCREASE = CustomerCreditIncreaseProcessor.FIXED_AMOUNT;
private static String[] customers = { "INSERT INTO customer (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)",
"INSERT INTO customer (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)",
"INSERT INTO customer (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)",
"INSERT INTO customer (id, version, name, credit) VALUES (4, 0, 'customer4', 100000)"};
private static String[] customers = { "INSERT INTO CUSTOMER (id, version, name, credit) VALUES (1, 0, 'customer1', 100000)",
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (2, 0, 'customer2', 100000)",
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (3, 0, 'customer3', 100000)",
"INSERT INTO CUSTOMER (id, version, name, credit) VALUES (4, 0, 'customer4', 100000)"};
private static String DELETE_CUSTOMERS = "DELETE FROM customer";
private static String DELETE_CUSTOMERS = "DELETE FROM CUSTOMER";
private static final String ALL_CUSTOMERS = "select * from CUSTOMER order by ID";

View File

@@ -25,7 +25,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@ContextConfiguration()
public class CompositeItemWriterSampleFunctionalTests extends AbstractValidatingBatchLauncherTests {
private static final String GET_TRADES = "SELECT isin, quantity, price, customer FROM trade order by isin";
private static final String GET_TRADES = "SELECT isin, quantity, price, customer FROM TRADE order by isin";
private static final String EXPECTED_OUTPUT_FILE = "Trade: [isin=UK21341EAH41,quantity=211,price=31.11,customer=customer1]"
+ "Trade: [isin=UK21341EAH42,quantity=212,price=32.11,customer=customer2]"

View File

@@ -60,7 +60,8 @@ public class CustomerFilterJobFunctionalTests extends AbstractJobTests {
public void onSetUp() throws Exception {
simpleJdbcTemplate.update("delete from TRADE");
simpleJdbcTemplate.update("delete from CUSTOMER where ID > 4");
List<Map<String, Object>> list = simpleJdbcTemplate.queryForList("select name, CREDIT from customer");
simpleJdbcTemplate.update("update CUSTOMER set credit=100000");
List<Map<String, Object>> list = simpleJdbcTemplate.queryForList("select name, CREDIT from CUSTOMER");
for (Map<String, Object> map : list) {
credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue());
}

View File

@@ -61,7 +61,7 @@ public class TradeJobFunctionalTests extends AbstractValidatingBatchLauncherTest
@Before
public void onSetUp() throws Exception {
simpleJdbcTemplate.update("delete from TRADE");
List<Map<String, Object>> list = simpleJdbcTemplate.queryForList("select name, CREDIT from customer");
List<Map<String, Object>> list = simpleJdbcTemplate.queryForList("select name, CREDIT from CUSTOMER");
for (Map<String, Object> map : list) {
credits.put((String) map.get("NAME"), ((Number) map.get("CREDIT")).doubleValue());
}

View File

@@ -51,7 +51,7 @@ public class JdbcCustomerDebitDaoTests {
public void testWrite() {
//insert customer credit
simpleJdbcTemplate.getJdbcOperations().execute("INSERT INTO customer VALUES (99, 0, 'testName', 100)");
simpleJdbcTemplate.getJdbcOperations().execute("INSERT INTO CUSTOMER VALUES (99, 0, 'testName', 100)");
//create customer debit
CustomerDebit customerDebit = new CustomerDebit();
@@ -62,7 +62,7 @@ public class JdbcCustomerDebitDaoTests {
writer.write(customerDebit);
//verify customer credit
simpleJdbcTemplate.getJdbcOperations().query("SELECT name, credit FROM customer WHERE name = 'testName'",
simpleJdbcTemplate.getJdbcOperations().query("SELECT name, credit FROM CUSTOMER WHERE name = 'testName'",
new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
assertEquals(95, rs.getLong("credit"));