All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.landawn.abacus.util.AsyncSQLExecutor Maven / Gradle / Ivy

There is a newer version: 1.2.9
Show newest version
/*
 * Copyright (C) 2015 HaiYang Li
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

package com.landawn.abacus.util;

import java.sql.Connection;
import java.util.List;
import java.util.concurrent.Callable;

import com.landawn.abacus.DataSet;
import com.landawn.abacus.logging.Logger;
import com.landawn.abacus.logging.LoggerFactory;
import com.landawn.abacus.util.SQLExecutor.JdbcSettings;
import com.landawn.abacus.util.SQLExecutor.ResultSetExtractor;
import com.landawn.abacus.util.SQLExecutor.StatementSetter;
import com.landawn.abacus.util.stream.Stream;

/**
 * Asynchronous SQLExecutor.
 * 
 * @since 0.8
 * 
 * @author Haiyang Li
 */
public final class AsyncSQLExecutor {
    protected static final Logger logger = LoggerFactory.getLogger(AsyncSQLExecutor.class);

    private final SQLExecutor sqlExecutor;
    private final AsyncExecutor asyncExecutor;

    AsyncSQLExecutor(final SQLExecutor sqlExecutor, final AsyncExecutor asyncExecutor) {
        this.sqlExecutor = sqlExecutor;
        this.asyncExecutor = asyncExecutor;
    }

    public SQLExecutor sync() {
        return sqlExecutor;
    }

    AsyncExecutor asyncExecutor() {
        return asyncExecutor;
    }

    @SafeVarargs
    public final  CompletableFuture insert(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture insert(final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(sql, statementSetter, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture insert(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture insert(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture insert(final Connection conn, final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(conn, sql, statementSetter, parameters);
            }
        });
    }

    /**
     * @see SQLExecutor#insert(Connection, String, StatementSetter, JdbcSettings, Object...)
     */
    @SafeVarargs
    public final  CompletableFuture insert(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.insert(conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture> batchInsert(final String sql, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, batchParameters);
            }
        });
    }

     CompletableFuture> batchInsert(final String sql, final StatementSetter statementSetter, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, statementSetter, batchParameters);
            }
        });
    }

     CompletableFuture> batchInsert(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

     CompletableFuture> batchInsert(final Connection conn, final String sql, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, batchParameters);
            }
        });
    }

     CompletableFuture> batchInsert(final Connection conn, final String sql, final StatementSetter statementSetter, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, statementSetter, batchParameters);
            }
        });
    }

     CompletableFuture> batchInsert(final Connection conn, final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final String sql, final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final String sql, final StatementSetter statementSetter, final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, statementSetter, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final Connection conn, final String sql, final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final Connection conn, final String sql, final StatementSetter statementSetter,
            final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, statementSetter, batchParameters);
            }
        });
    }

    public  CompletableFuture> batchInsert(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final List batchParameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.batchInsert(conn, sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(sql, statementSetter, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final Connection conn, final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(conn, sql, statementSetter, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture update(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.update(conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture batchUpdate(final String sql, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, batchParameters);
            }
        });
    }

    CompletableFuture batchUpdate(final String sql, final StatementSetter statementSetter, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, statementSetter, batchParameters);
            }
        });
    }

    CompletableFuture batchUpdate(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    CompletableFuture batchUpdate(final Connection conn, final String sql, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, batchParameters);
            }
        });
    }

    CompletableFuture batchUpdate(final Connection conn, final String sql, final StatementSetter statementSetter, final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, statementSetter, batchParameters);
            }
        });
    }

    CompletableFuture batchUpdate(final Connection conn, final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object[] batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final String sql, final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final String sql, final StatementSetter statementSetter, final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, statementSetter, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final Connection conn, final String sql, final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final Connection conn, final String sql, final StatementSetter statementSetter,
            final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, statementSetter, batchParameters);
            }
        });
    }

    public CompletableFuture batchUpdate(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final List batchParameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.batchUpdate(conn, sql, statementSetter, jdbcSettings, batchParameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture exists(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Boolean call() throws Exception {
                return sqlExecutor.exists(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture exists(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Boolean call() throws Exception {
                return sqlExecutor.exists(conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture count(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.count(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture count(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Integer call() throws Exception {
                return sqlExecutor.count(conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture get(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.get(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture get(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.get(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture get(final Class targetClass, final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.get(targetClass, conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture get(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.get(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> gett(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.gett(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> gett(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.gett(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> gett(final Class targetClass, final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.gett(targetClass, conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> gett(final Class targetClass, final Connection conn, final String sql,
            final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.gett(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> find(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.find(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> find(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.find(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> find(final Class targetClass, final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.find(targetClass, conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> find(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.find(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> findAll(final Class targetClass, final String sql, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, sql, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> findAll(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture> findAll(final Class targetClass, final Connection conn, final String sql, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, conn, sql, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture> findAll(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> findAll(final Class targetClass, final List sqls, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, sqls, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> findAll(final Class targetClass, final List sqls, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture> findAll(final Class targetClass, final Connection conn, final List sqls, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, conn, sqls, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture> findAll(final Class targetClass, final Connection conn, final List sqls, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public List call() throws Exception {
                return sqlExecutor.findAll(targetClass, conn, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForBoolean(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalBoolean call() throws Exception {
                return sqlExecutor.queryForBoolean(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForChar(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalChar call() throws Exception {
                return sqlExecutor.queryForChar(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForByte(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalByte call() throws Exception {
                return sqlExecutor.queryForByte(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForShort(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalShort call() throws Exception {
                return sqlExecutor.queryForShort(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForInt(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalInt call() throws Exception {
                return sqlExecutor.queryForInt(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForLong(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalLong call() throws Exception {
                return sqlExecutor.queryForLong(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForFloat(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalFloat call() throws Exception {
                return sqlExecutor.queryForFloat(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryForDouble(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public OptionalDouble call() throws Exception {
                return sqlExecutor.queryForDouble(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture> queryForString(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return sqlExecutor.queryForString(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForSingleResult(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return sqlExecutor.queryForSingleResult(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForSingleResult(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return sqlExecutor.queryForSingleResult(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForSingleResult(final Class targetClass, final Connection conn, final String sql,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return sqlExecutor.queryForSingleResult(targetClass, conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForSingleResult(final Class targetClass, final Connection conn, final String sql,
            final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Nullable call() throws Exception {
                return sqlExecutor.queryForSingleResult(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    //
    //    public CompletableFuture> queryForMap(final String sql, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable>() {
    //            @Override
    //            public Map call() throws Exception {
    //                return sqlExecutor.queryForMap(sql, parameters);
    //            }
    //        });
    //    }
    //
    //    public CompletableFuture> queryForMap(final String sql, final StatementSetter statementSetter, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable>() {
    //            @Override
    //            public Map call() throws Exception {
    //                return sqlExecutor.queryForMap(sql, statementSetter, parameters);
    //            }
    //        });
    //    }
    //
    //    public CompletableFuture> queryForMap(final Connection conn, final String sql, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable>() {
    //            @Override
    //            public Map call() throws Exception {
    //                return sqlExecutor.queryForMap(conn, sql, parameters);
    //            }
    //        });
    //    }
    //
    //    public CompletableFuture> queryForMap(final Connection conn, final String sql, final StatementSetter statementSetter, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable>() {
    //            @Override
    //            public Map call() throws Exception {
    //                return sqlExecutor.queryForMap(conn, sql, statementSetter, parameters);
    //            }
    //        });
    //    }
    //
    @SafeVarargs
    public final  CompletableFuture> queryForEntity(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.queryForEntity(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForEntity(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.queryForEntity(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForEntity(final Class targetClass, final Connection conn, final String sql,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.queryForEntity(targetClass, conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture> queryForEntity(final Class targetClass, final Connection conn, final String sql,
            final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>() {
            @Override
            public Optional call() throws Exception {
                return sqlExecutor.queryForEntity(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture query(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.query(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture query(final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.query(sql, statementSetter, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture query(final String sql, final StatementSetter statementSetter, final ResultSetExtractor resultSetExtractor,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.query(sql, statementSetter, resultSetExtractor, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture query(final String sql, final StatementSetter statementSetter, final ResultSetExtractor resultSetExtractor,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.query(sql, statementSetter, resultSetExtractor, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture query(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.query(conn, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture query(final Connection conn, final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.query(conn, sql, statementSetter, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture query(final Connection conn, final String sql, final StatementSetter statementSetter,
            final ResultSetExtractor resultSetExtractor, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.query(conn, sql, statementSetter, resultSetExtractor, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture query(final Connection conn, final String sql, final StatementSetter statementSetter,
            final ResultSetExtractor resultSetExtractor, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public T call() throws Exception {
                return sqlExecutor.query(conn, sql, statementSetter, resultSetExtractor, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryAll(final String sql, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(sql, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryAll(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture queryAll(final Connection conn, final String sql, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(conn, sql, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture queryAll(final Connection conn, final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryAll(final List sqls, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(sqls, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture queryAll(final List sqls, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture queryAll(final Connection conn, final List sqls, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(conn, sqls, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture queryAll(final Connection conn, final List sqls, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public DataSet call() throws Exception {
                return sqlExecutor.queryAll(conn, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture>> stream(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture>> stream(final String sql, final StatementSetter statementSetter, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(sql, statementSetter, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet.
     * 
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final CompletableFuture>> stream(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture>> stream(final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(conn, sql, parameters);
            }
        });
    }

    CompletableFuture>> stream(final Connection conn, final String sql, final StatementSetter statementSetter,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(conn, sql, statementSetter, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet.
     * 
     * @param conn
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    CompletableFuture>> stream(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture>> streamAll(final String sql, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(sql, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet list.
     * 
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final CompletableFuture>> streamAll(final String sql, final StatementSetter statementSetter, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture>> streamAll(final Connection conn, final String sql, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(conn, sql, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Returns the merged ResultSet acquired by querying with the specified sql in parallel. Mostly it's designed
     * for partition to query the partitioning table in more than one databases.
     *
     * @param conn
     * @param sql
     * @param statementSetter
     * @param jdbcSettings set multiple data sources by method: setQueryWithDataSources
     * @param parameters
     * @return
     */
    CompletableFuture>> streamAll(final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture>> streamAll(final List sqls, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(sqls, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet list.
     * 
     * @param sqls
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final CompletableFuture>> streamAll(final List sqls, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    CompletableFuture>> streamAll(final Connection conn, final List sqls, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(conn, sqls, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Returns the merged ResultSet acquired by querying with the specified sql list in parallel. Mostly it's designed
     * for partition to query multiple partitioning tables in one or more databases.
     *
     * @param conn
     * @param sqls
     * @param statementSetter
     * @param jdbcSettings set multiple data sources by method: setQueryWithDataSources
     * @param parameters
     * @return
     */
    CompletableFuture>> streamAll(final Connection conn, final List sqls, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(conn, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture>> stream(final Class targetClass, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, sql, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture>> stream(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, sql, statementSetter, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet.
     * 
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final  CompletableFuture>> stream(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture>> stream(final Class targetClass, final Connection conn, final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, conn, sql, parameters);
            }
        });
    }

     CompletableFuture>> stream(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, conn, sql, statementSetter, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet.
     * 
     * @param conn
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
     CompletableFuture>> stream(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.stream(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture>> streamAll(final Class targetClass, final String sql, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, sql, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet list.
     * 
     * @param sql
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final  CompletableFuture>> streamAll(final Class targetClass, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture>> streamAll(final Class targetClass, final Connection conn, final String sql, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, conn, sql, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Returns the merged ResultSet acquired by querying with the specified sql in parallel. Mostly it's designed
     * for partition to query the partitioning table in more than one databases.
     *
     * @param conn
     * @param sql
     * @param statementSetter
     * @param jdbcSettings set multiple data sources by method: setQueryWithDataSources
     * @param parameters
     * @return
     */
     CompletableFuture>> streamAll(final Class targetClass, final Connection conn, final String sql, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, conn, sql, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final  CompletableFuture>> streamAll(final Class targetClass, final List sqls, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, sqls, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Remember to close the returned Stream to close the underlying ResultSet list.
     * 
     * @param sqls
     * @param statementSetter
     * @param jdbcSettings
     * @param parameters
     * @return
     */
    @SafeVarargs
    public final  CompletableFuture>> streamAll(final Class targetClass, final List sqls, final StatementSetter statementSetter,
            final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

     CompletableFuture>> streamAll(final Class targetClass, final Connection conn, final List sqls, final JdbcSettings jdbcSettings,
            final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, conn, sqls, jdbcSettings, parameters);
            }
        });
    }

    /**
     * Returns the merged ResultSet acquired by querying with the specified sql list in parallel. Mostly it's designed
     * for partition to query multiple partitioning tables in one or more databases.
     *
     * @param conn
     * @param sqls
     * @param statementSetter
     * @param jdbcSettings set multiple data sources by method: setQueryWithDataSources
     * @param parameters
     * @return
     */
     CompletableFuture>> streamAll(final Class targetClass, final Connection conn, final List sqls,
            final StatementSetter statementSetter, final JdbcSettings jdbcSettings, final Object... parameters) {
        return asyncExecutor.execute(new Callable>>() {
            @Override
            public Try> call() throws Exception {
                return sqlExecutor.streamAll(targetClass, conn, sqls, statementSetter, jdbcSettings, parameters);
            }
        });
    }

    @SafeVarargs
    public final CompletableFuture execute(final String sql, final Object... parameters) {
        return asyncExecutor.execute(new Callable() {
            @Override
            public Void call() throws Exception {
                sqlExecutor.execute(sql, parameters);
                return null;
            }
        });
    }

    //    public CompletableFuture executeUpdate(final String sql, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable() {
    //            @Override
    //            public Integer call() throws Exception {
    //                return sqlExecutor.executeUpdate(sql, parameters);
    //            }
    //        });
    //    }
    //
    //    /**
    //     * Don't forget to close the returned ResultSet.
    //     * 
    //     * @param sql
    //     * @param parameters
    //     * @return
    //     */
    //    public CompletableFuture executeQuery(final String sql, final Object... parameters) {
    //        return asyncExecutor.execute(new Callable() {
    //            @Override
    //            public ResultSet call() throws Exception {
    //                return sqlExecutor.executeQuery(sql, parameters);
    //            }
    //        });
    //    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy