[Spring] 12. Spring JDBC - RowMapper를 활용한 조회결과 매핑


[Spring] 12. Spring JDBC - RowMapper를 활용한 조회결과 매핑

#20201109 #SpringFramework #스프링프레임워크 #스프링 #스프링JDBC #JDBC #JdbcTemplate #RowMapper #BeanPropertyRowMapper JdbcTemplate 클래스를 이용하여 SQL질의를 할 때, 조회 결과를 사용자가 정의한 클래스의 인스턴스 형태로 리턴하게 할 수 있다. 이 때, 사용되는 인터페이스가 RowMapper이다. RowMapper 인터페이스를 구현하여 SQL 조회 결과의 ResultSet을 POJO 형태로 변환해보도록 한다. 또, RowMapper 인터페이스를 직접 구현하지 않고도 자바의 리플렉션 Reflection 기능을 이용하여 자동으로 매핑해주는 방법 또한 알아본다. RowMapper Interface @FunctionalInterface public interface RowMapper<T> { @Nullable T mapRow(ResultSet rs, int rowNum) throws SQLException; ...


#20201109 #BeanPropertyRowMapper #JDBC #JdbcTemplate #RowMapper #SpringFramework #스프링 #스프링JDBC #스프링프레임워크

원문링크 : [Spring] 12. Spring JDBC - RowMapper를 활용한 조회결과 매핑