@Test public void testQueryUsers() { List<User> users = userDao.queryUsers(); assertNotNull(users); assertTrue(users.size()>0); }
public List<User> queryUsers() { String sql = "select * from TBL_USERS"; return this.jdbcTemplate.query( sql, new Object[]{}, new RowMapper<User>() { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); user.setPubDate(rs.getDate("pub_date")); user.setDepartId(rs.getInt("depart_id")); return user; } }); }
UserDao { public List<User> queryUsers() { String sql = "select * from TBL_USERS"; return this.jdbcTemplate.query( sql, new Object[]{}, new RowMapper<User>() { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); user.setPubDate(rs.getDate("pub_date")); user.setDepartId(rs.getInt("depart_id")); return user; } }); } }
UserDao { public List<User> queryUsers() { String sql = "select * from TBL_USERS"; return this.jdbcTemplate.query( sql, new Object[]{}, new RowMapper<User>() { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); user.setPubDate(rs.getDate("pub_date")); user.setDepartId(rs.getInt("depart_id")); return user; } }); }  }
UserDao { public List<User> queryUsers() { String sql = "select * from TBL_USERS"; return this.jdbcTemplate.query( sql, new Object[]{}, new RowMapper<User>() { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); user.setPubDate(rs.getDate("pub_date")); user.setDepartId(rs.getInt("depart_id")); return user; } }); }  List<User> queryUsers(); Department queryDepartment(int departId); }
UserDao { public List<User> queryUsers() { String sql = "select * from TBL_USERS"; return this.jdbcTemplate.query( sql, new Object[]{}, new RowMapper<User>() { public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getInt("id")); user.setName(rs.getString("name")); user.setPubDate(rs.getDate("pub_date")); user.setDepartId(rs.getInt("depart_id")); return user; } }); }  List<User> queryUsers(); Department queryDepartment(int departId);  }