// Path: sane-dbc-core/src/main/java/com/novarto/sanedbc/core/ops/Binders.java
// public static <A> Try1<PreparedStatement, Option<Integer>, SQLException> batchBinder(
//         F<A, TryEffect1<PreparedStatement, SQLException>> binder, Iterable<A> as)
// {
//     return ps -> {
//         for (A a : as)
//         {
//             binder.f(a).f(ps);
//             ps.addBatch();
//         }
//         return sumBatchResult(ps.executeBatch());
// 
//     };
// }


import com.novarto.lang.CanBuildFrom;
import com.novarto.lang.Collections;
import fj.F;
import fj.control.db.DB;
import fj.data.Option;
import fj.function.Try1;
import fj.function.TryEffect1;
import java.sql.*;
import static com.novarto.sanedbc.core.ops.Binders.batchBinder;
package com.novarto.sanedbc.core.ops;




/**
 * Batch insert operation which returns the auto-generated keys created for the inserted entries. Please consider that the used
 * JDBC driver may not support the retrieval of auto-generated key and this operation may fail with {@link
 * SQLFeatureNotSupportedException}
 *
 * @param <A>  Type of single entry to be inserted
 * @param <B>  Type of the result which must extend {@link Number}
 * @param <C1> The type of the optional (mutable) buffer which is intermediately used while constructing the result.
 * @param <C2> Type of the result
 * @see Statement#getGeneratedKeys()
 */
public abstract class BatchInsertGenKeysOp<A, B extends Number, C1 extends Iterable<B>, C2 extends Iterable<B>> extends DB<C2>

{
    private final String sql;
    private final Try1<PreparedStatement, Option<Integer>, SQLException> binder;
    private final Try1<ResultSet, B, SQLException> getKey;
    private final CanBuildFrom<B, C1, C2> cbf;
    private final Iterable<A> as;

    public BatchInsertGenKeysOp(String sql, F<A, TryEffect1<PreparedStatement, SQLException>> binder, Iterable<A> as,
            Try1<ResultSet, B, SQLException> getKey, CanBuildFrom<B, C1, C2> cbf)
    {
        this.sql = sql;
// Path: sane-dbc-core/src/main/java/com/novarto/sanedbc/core/ops/Binders.java
// public static <A> Try1<PreparedStatement, Option<Integer>, SQLException> batchBinder(
//         F<A, TryEffect1<PreparedStatement, SQLException>> binder, Iterable<A> as)
// {
//     return ps -> {
//         for (A a : as)
//         {
//             binder.f(a).f(ps);
//             ps.addBatch();
//         }
//         return sumBatchResult(ps.executeBatch());
// 
//     };
// }


// Path: sane-dbc-core/src/main/java/com/novarto/sanedbc/core/ops/BatchInsertGenKeysOp.java
import com.novarto.lang.CanBuildFrom;
import com.novarto.lang.Collections;
import fj.F;
import fj.control.db.DB;
import fj.data.Option;
import fj.function.Try1;
import fj.function.TryEffect1;
import java.sql.*;
import static com.novarto.sanedbc.core.ops.Binders.batchBinder;

package com.novarto.sanedbc.core.ops;




/**
 * Batch insert operation which returns the auto-generated keys created for the inserted entries. Please consider that the used
 * JDBC driver may not support the retrieval of auto-generated key and this operation may fail with {@link
 * SQLFeatureNotSupportedException}
 *
 * @param <A>  Type of single entry to be inserted
 * @param <B>  Type of the result which must extend {@link Number}
 * @param <C1> The type of the optional (mutable) buffer which is intermediately used while constructing the result.
 * @param <C2> Type of the result
 * @see Statement#getGeneratedKeys()
 */
public abstract class BatchInsertGenKeysOp<A, B extends Number, C1 extends Iterable<B>, C2 extends Iterable<B>> extends DB<C2>

{
    private final String sql;
    private final Try1<PreparedStatement, Option<Integer>, SQLException> binder;
    private final Try1<ResultSet, B, SQLException> getKey;
    private final CanBuildFrom<B, C1, C2> cbf;
    private final Iterable<A> as;

    public BatchInsertGenKeysOp(String sql, F<A, TryEffect1<PreparedStatement, SQLException>> binder, Iterable<A> as,
            Try1<ResultSet, B, SQLException> getKey, CanBuildFrom<B, C1, C2> cbf)
    {
        this.sql = sql;
        this.binder = batchBinder(binder, as);