@Test public void testFetchByYearAndTeamName_2014() { log.info("*** BEGIN Test ***"); Integer year = 2014; String teamName = "Kentucky"; SeasonData result = classUnderTest.fetchByYearAndTeamName(year, teamName); assertEquals("Kentucky", result.getTeamName()); log.info("*** END Test ***"); }
@Override public SeasonData fetchByYearAndTeamName(Integer year, String teamName) { SeasonData ret = null; String sql = "SELECT t.* FROM " + TABLE_NAME + " t WHERE t.year = ? AND t.team_name = ?"; Object[] args = { year, teamName }; List<SeasonData> results = getJdbcTemplate().query(sql, args, new SeasonDataRowMapper()); if (results.size() > 0) { if (results.size() > 1) { log.warn("Expected 1 result from query, instead got " + results.size() + "!"); } ret = results.get(0); } else { log.warn("Requested team/year combination (" + teamName + "/" + year + ") does not exist in the DB!"); } return ret; }
SeasonDataJdbcDao extends JdbcDaoSupport implements SeasonDataDao { @Override public SeasonData fetchByYearAndTeamName(Integer year, String teamName) { SeasonData ret = null; String sql = "SELECT t.* FROM " + TABLE_NAME + " t WHERE t.year = ? AND t.team_name = ?"; Object[] args = { year, teamName }; List<SeasonData> results = getJdbcTemplate().query(sql, args, new SeasonDataRowMapper()); if (results.size() > 0) { if (results.size() > 1) { log.warn("Expected 1 result from query, instead got " + results.size() + "!"); } ret = results.get(0); } else { log.warn("Requested team/year combination (" + teamName + "/" + year + ") does not exist in the DB!"); } return ret; } }
SeasonDataJdbcDao extends JdbcDaoSupport implements SeasonDataDao { @Override public SeasonData fetchByYearAndTeamName(Integer year, String teamName) { SeasonData ret = null; String sql = "SELECT t.* FROM " + TABLE_NAME + " t WHERE t.year = ? AND t.team_name = ?"; Object[] args = { year, teamName }; List<SeasonData> results = getJdbcTemplate().query(sql, args, new SeasonDataRowMapper()); if (results.size() > 0) { if (results.size() > 1) { log.warn("Expected 1 result from query, instead got " + results.size() + "!"); } ret = results.get(0); } else { log.warn("Requested team/year combination (" + teamName + "/" + year + ") does not exist in the DB!"); } return ret; } SeasonDataJdbcDao(DataSource dataSource); }
SeasonDataJdbcDao extends JdbcDaoSupport implements SeasonDataDao { @Override public SeasonData fetchByYearAndTeamName(Integer year, String teamName) { SeasonData ret = null; String sql = "SELECT t.* FROM " + TABLE_NAME + " t WHERE t.year = ? AND t.team_name = ?"; Object[] args = { year, teamName }; List<SeasonData> results = getJdbcTemplate().query(sql, args, new SeasonDataRowMapper()); if (results.size() > 0) { if (results.size() > 1) { log.warn("Expected 1 result from query, instead got " + results.size() + "!"); } ret = results.get(0); } else { log.warn("Requested team/year combination (" + teamName + "/" + year + ") does not exist in the DB!"); } return ret; } SeasonDataJdbcDao(DataSource dataSource); @Override List<SeasonData> fetchAllByYear(Integer year); @Override SeasonData fetchByYearAndTeamName(Integer year, String teamName); }
SeasonDataJdbcDao extends JdbcDaoSupport implements SeasonDataDao { @Override public SeasonData fetchByYearAndTeamName(Integer year, String teamName) { SeasonData ret = null; String sql = "SELECT t.* FROM " + TABLE_NAME + " t WHERE t.year = ? AND t.team_name = ?"; Object[] args = { year, teamName }; List<SeasonData> results = getJdbcTemplate().query(sql, args, new SeasonDataRowMapper()); if (results.size() > 0) { if (results.size() > 1) { log.warn("Expected 1 result from query, instead got " + results.size() + "!"); } ret = results.get(0); } else { log.warn("Requested team/year combination (" + teamName + "/" + year + ") does not exist in the DB!"); } return ret; } SeasonDataJdbcDao(DataSource dataSource); @Override List<SeasonData> fetchAllByYear(Integer year); @Override SeasonData fetchByYearAndTeamName(Integer year, String teamName);  }