public void read(int count, Object object) {
   Game game = (Game) object;
   try {
     gameService.addGame(game);
   } catch (GameServiceException se) {
     logger.warning("Game id " + game.getGameId() + " not added " + se.getMessage());
   }
 }
Example #2
0
  public void addGame(Game game) throws GameServiceException {
    SimpleJdbcInsert insertGame = new SimpleJdbcInsert(getDataSource()).withTableName("games");
    Map<String, Object> gameParameters = new HashMap<String, Object>(5);
    gameParameters.put("gameid", game.getGameId());
    gameParameters.put("startTime", game.getStartTime());
    gameParameters.put("teamHomeid", game.getTeamHome().getTeamId());
    gameParameters.put("teamAwayid", game.getTeamAway().getTeamId());
    gameParameters.put("venueid", game.getVenue().getVenueId());

    try {
      insertGame.execute(gameParameters);
    } catch (DataIntegrityViolationException divex) {
      log.warning("Duplicate entry");
      throw new GameServiceException(divex.getMessage(), divex);
    }
  }