BATCH-711:Modified ItemWriter interface to use parameterized types. Updated a portion of classes using ItemWriter as well.

This commit is contained in:
lucasward
2008-07-21 04:19:54 +00:00
parent d8ba0b6fbd
commit 0ef196d578
2 changed files with 4 additions and 15 deletions

View File

@@ -5,19 +5,14 @@ import org.springframework.batch.item.FlushFailedException;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.sample.domain.Game;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.util.Assert;
public class JdbcGameDao extends JdbcDaoSupport implements ItemWriter {
public class JdbcGameDao extends JdbcDaoSupport implements ItemWriter<Game> {
private static final String INSERT_GAME = "INSERT into GAMES(player_id,year_no,team,week,opponent,"
+ "completes,attempts,passing_yards,passing_td,interceptions,rushes,rush_yards,"
+ "receptions,receptions_yards,total_td) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
public void write(Object output) {
Assert.isTrue(output instanceof Game,
"Only Game objects can be written out" + "using this Dao");
Game game = (Game) output;
public void write(Game game) {
Object[] args = new Object[] { game.getId(),
new Integer(game.getYear()), game.getTeam(),

View File

@@ -5,20 +5,14 @@ import org.springframework.batch.item.FlushFailedException;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.sample.domain.PlayerSummary;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.util.Assert;
public class JdbcPlayerSummaryDao extends JdbcDaoSupport implements ItemWriter {
public class JdbcPlayerSummaryDao extends JdbcDaoSupport implements ItemWriter<PlayerSummary> {
private static final String INSERT_SUMMARY = "INSERT into PLAYER_SUMMARY(ID,YEAR_NO,COMPLETES,ATTEMPTS," +
"PASSING_YARDS,PASSING_TD,INTERCEPTIONS,RUSHES,RUSH_YARDS,RECEPTIONS,RECEPTIONS_YARDS," +
"TOTAL_TD) values(?,?,?,?,?,?,?,?,?,?,?,?)";
public void write(Object output) {
Assert.isInstanceOf(PlayerSummary.class, output, JdbcPlayerSummaryDao.class.getName() + " only " +
"supports outputing " + PlayerSummary.class.getName() + " instances.");
PlayerSummary summary = (PlayerSummary)output;
public void write(PlayerSummary summary) {
Object[] args = new Object[]{summary.getId(), new Integer(summary.getYear()),
new Integer(summary.getCompletes()), new Integer(summary.getAttempts()),