테이블의 모든 로우를 가져온다
데이터 포맷:
- get() 메서드는 하나의 로우를 User 오브젝트에 담았다
리스트에 담는 순서: 기본키인 id 순으로 정렬
// UserDao.class
public List<User> getAll() {
return this.jdbcTemplate.query("select * from users order by id",
new RowMapper<User>() {
public User mapRow(ResultSet rs, int rowNum) throws SQLException{
User user = new User();
user.setId(rs.getString("id"));
user.setName(rs.getString("name"));
user.setPassword(rs.getString("password"));
return user;
}
});
}
첫번째 파라미터 select * from users order by id
마지막 파라미터 RowMapper 콜백