【JDBC】SimpleJdbcInsertで複数の要素を一気にInsertする

BeanPropertySqlParameterSourceの配列を作ってSimpleJdbcInsert#executeBatchに入れるとできます。

//配列を作る関数
private BeanPropertySqlParameterSource[] makeParamArray(List entities){
    BeanPropertySqlParameterSource[] sources = new BeanPropertySqlParameterSource[entities.size()];
    for(int i = 0; i < entities.size(); i++){
        sources[i] = new BeanPropertySqlParameterSource(entities.get(i));
    }
    return sources;
}

//インサート例
public void insertテーブル名(List<[Entity]> entities) {
    SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert(jdbcTemplate).withTableName("[テーブル名]");
    jdbcInsert.executeBatch(makeParamArray(entities));
}