protected <RH extends CheckedConsumer<? super K>> RH executeQueryPreparerInBatchMode(Connection connection, Collection<T> values, RH keyConsumer, QueryPreparer<T> queryPreparer) throws SQLException { PreparedStatement preparedStatement = queryPreparer.prepareStatement(connection); try { FieldMapper<T, PreparedStatement> mapper = queryPreparer.mapper(); for (T value : values) { mapper.mapTo(value, preparedStatement, null); preparedStatement.addBatch(); } preparedStatement.executeBatch(); if (hasGeneratedKeys && keyConsumer != null) { handleGeneratedKeys(keyConsumer, preparedStatement); } return keyConsumer; } catch(Exception e) { ErrorHelper.rethrow(e); } finally { safeClose(preparedStatement); } return keyConsumer; }
protected <RH extends CheckedConsumer<? super K>> RH executeQueryPreparerInBatchMode(Connection connection, Collection<T> values, RH keyConsumer, QueryPreparer<T> queryPreparer) throws SQLException { PreparedStatement preparedStatement = queryPreparer.prepareStatement(connection); try { FieldMapper<T, PreparedStatement> mapper = queryPreparer.mapper(); for (T value : values) { mapper.mapTo(value, preparedStatement, null); preparedStatement.addBatch(); } preparedStatement.executeBatch(); if (hasGeneratedKeys && keyConsumer != null) { handleGeneratedKeys(keyConsumer, preparedStatement); } return keyConsumer; } catch(Exception e) { ErrorHelper.rethrow(e); } finally { safeClose(preparedStatement); } return keyConsumer; }