public void saveAll(PGConnection connection, Stream<TEntity> entities) throws SQLException {

        try (PgBinaryWriter bw = new PgBinaryWriter(configuration.getBufferSize())) {

            // Wrap the CopyOutputStream in our own Writer:
            bw.open(new PGCopyOutputStream(connection, mapping.getCopyCommand(), 1));

            // Insert Each Column:
            entities.forEach(entity -> saveEntitySynchonized(bw, entity));
        }
    }
public void saveAll ( PGConnection connection , Stream < TEntity > entities ) throws SQLException { try ( PgBinaryWriter bw = new PgBinaryWriter ( configuration . getBufferSize ( ) ) ) { bw . open ( new PGCopyOutputStream ( connection , mapping . getCopyCommand ( ) , 1 ) ) ; entities . forEach ( entity -> saveEntitySynchonized ( bw , entity ) ) ; } }
Save stream of entities

@param connection underlying db connection
@param entities stream of entities
@throws SQLException