Java

SimpleJdbcInsert

SimpleJdbcInsert는 테이블 명과 컬럼 명만 명시해주면 쿼리문 없이 쉽게 Insert 쿼리를 처리할 수 있다. 

final SimpleJdbcInsert simpleJdbcInsert = new SimpleJdbcInsert(jdbcTemplate)
                .withTableName("테이블명")
                .usingGeneratedKeyColumns("키 컬럼");

Map<String, Object> params = new HashMap<>(담을 값의 개수);
params.put("컬럼명", 넣을 값);
Long id = simpleJdbcInsert.executeAndReturnKey(params).longValue();

 

 

참고 자료

- docs.spring.io/spring-framework/docs/current/javadoc--api/org/springframework/jdbc/core/simple/SimpleJdbcInsert.html

 

SimpleJdbcInsert (Spring Framework 5.3.6 API)

A SimpleJdbcInsert is a multi-threaded, reusable object providing easy insert capabilities for a table. It provides meta-data processing to simplify the code needed to construct a basic insert statement. All you need to provide is the name of the table and

docs.spring.io