[#5012] Add CompletionStage<Result<R>> ResultQuery.fetchAsync() and fetchAsync(Executor)
This commit is contained in:
parent
6cfeaa110c
commit
0806dee1c6
@ -75,6 +75,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
@ -772,6 +775,253 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
Cursor<Record> fetchLazy(String sql, QueryPart... parts) throws DataAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(SQL sql);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(String sql);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* There must be as many bind variables contained in the SQL, as passed in
|
||||
* the bindings parameter
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @param bindings The bindings
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(String sql, Object... bindings);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* Unlike {@link #fetchLazy(String, Object...)}, the SQL passed to this
|
||||
* method should not contain any bind variables. Instead, you can pass
|
||||
* {@link QueryPart} objects to the method which will be rendered at indexed
|
||||
* locations of your SQL string as such: <code><pre>
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses! One way to escape
|
||||
* literals is to use {@link DSL#name(String...)} and similar methods
|
||||
*
|
||||
* @param sql The SQL clause, containing {numbered placeholders} where query
|
||||
* parts can be injected
|
||||
* @param parts The {@link QueryPart} objects that are rendered at the
|
||||
* {numbered placeholder} locations
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(String sql, QueryPart... parts);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, SQL sql);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* There must be as many bind variables contained in the SQL, as passed in
|
||||
* the bindings parameter
|
||||
* <p>
|
||||
* Example (Postgres):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "FETCH ALL IN \"<unnamed cursor 1>\"";</pre></code> Example
|
||||
* (SQLite):
|
||||
* <p>
|
||||
* <code><pre>
|
||||
* String sql = "pragma table_info('my_table')";</pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses!
|
||||
*
|
||||
* @param sql The SQL
|
||||
* @param bindings The bindings
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql, Object... bindings);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* Unlike {@link #fetchLazy(String, Object...)}, the SQL passed to this
|
||||
* method should not contain any bind variables. Instead, you can pass
|
||||
* {@link QueryPart} objects to the method which will be rendered at indexed
|
||||
* locations of your SQL string as such: <code><pre>
|
||||
* // The following query
|
||||
* fetchLazy("select {0}, {1} from {2}", val(1), inline("test"), name("DUAL"));
|
||||
*
|
||||
* // Will execute this SQL on an Oracle database with RenderNameStyle.QUOTED:
|
||||
* select ?, 'test' from "DUAL"
|
||||
* </pre></code>
|
||||
* <p>
|
||||
* <b>NOTE</b>: When inserting plain SQL into jOOQ objects, you must
|
||||
* guarantee syntax integrity. You may also create the possibility of
|
||||
* malicious SQL injection. Be sure to properly use bind variables and/or
|
||||
* escape literals when concatenated into SQL clauses! One way to escape
|
||||
* literals is to use {@link DSL#name(String...)} and similar methods
|
||||
*
|
||||
* @param sql The SQL clause, containing {numbered placeholders} where query
|
||||
* parts can be injected
|
||||
* @param parts The {@link QueryPart} objects that are rendered at the
|
||||
* {numbered placeholder} locations
|
||||
* @return The results from the executed query. This is never
|
||||
* <code>null</code>, even if the database returns no
|
||||
* {@link ResultSet}
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @see SQL
|
||||
*/
|
||||
@Support
|
||||
@PlainSQL
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql, QueryPart... parts);
|
||||
|
||||
/**
|
||||
* Execute a new query holding plain SQL and "lazily" return the generated
|
||||
* result.
|
||||
@ -2418,6 +2668,117 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
Cursor<Record> fetchLazy(ResultSet rs, Class<?>... types) throws DataAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @return The resulting jOOQ Result
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(ResultSet rs);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* The additional <code>fields</code> argument is used by jOOQ to coerce
|
||||
* field names and data types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param fields The fields to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(ResultSet rs, Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(ResultSet rs, DataType<?>... types);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(ResultSet rs, Class<?>... types);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @return The resulting jOOQ Result
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* The additional <code>fields</code> argument is used by jOOQ to coerce
|
||||
* field names and data types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param fields The fields to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, DataType<?>... types);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
* <p>
|
||||
* The additional <code>types</code> argument is used by jOOQ to coerce data
|
||||
* types to the desired output
|
||||
*
|
||||
* @param rs The JDBC ResultSet to fetch data from
|
||||
* @param types The data types to use in the desired output
|
||||
* @return The resulting jOOQ Result
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
*/
|
||||
@Support
|
||||
CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, Class<?>... types);
|
||||
|
||||
/**
|
||||
* Wrap a JDBC {@link ResultSet} into a jOOQ {@link Stream}.
|
||||
* <p>
|
||||
@ -7801,6 +8162,27 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
<R extends Record> Cursor<R> fetchLazy(ResultQuery<R> query) throws DataAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
*
|
||||
* @param query The query to execute
|
||||
* @return The result
|
||||
* @see ResultQuery#fetchAsync()
|
||||
*/
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(ResultQuery<R> query);
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
*
|
||||
* @param query The query to execute
|
||||
* @return The result
|
||||
* @see ResultQuery#fetchAsync()
|
||||
*/
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, ResultQuery<R> query);
|
||||
|
||||
/**
|
||||
* Execute a {@link ResultQuery} in the context of this <code>DSLContext</code> and return
|
||||
* a stream.
|
||||
@ -8170,6 +8552,51 @@ public interface DSLContext extends Scope , AutoCloseable {
|
||||
<R extends Record> Cursor<R> fetchLazy(Table<R> table, Condition condition) throws DataAccessException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Execute and return all records asynchronously for
|
||||
* <code><pre>SELECT * FROM [table]</pre></code>.
|
||||
* <p>
|
||||
* The result and its contained records are attached to this
|
||||
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
|
||||
* to override this behaviour.
|
||||
*/
|
||||
@Support
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(Table<R> table);
|
||||
|
||||
/**
|
||||
* Execute and return all records asynchronously for
|
||||
* <code><pre>SELECT * FROM [table] WHERE [condition] </pre></code>.
|
||||
* <p>
|
||||
* The result and its contained records are attached to this
|
||||
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
|
||||
* to override this behaviour.
|
||||
*/
|
||||
@Support
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(Table<R> table, Condition condition);
|
||||
|
||||
/**
|
||||
* Execute and return all records asynchronously for
|
||||
* <code><pre>SELECT * FROM [table]</pre></code>.
|
||||
* <p>
|
||||
* The result and its contained records are attached to this
|
||||
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
|
||||
* to override this behaviour.
|
||||
*/
|
||||
@Support
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, Table<R> table);
|
||||
|
||||
/**
|
||||
* Execute and return all records asynchronously for
|
||||
* <code><pre>SELECT * FROM [table] WHERE [condition] </pre></code>.
|
||||
* <p>
|
||||
* The result and its contained records are attached to this
|
||||
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
|
||||
* to override this behaviour.
|
||||
*/
|
||||
@Support
|
||||
<R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, Table<R> table, Condition condition);
|
||||
|
||||
/**
|
||||
* Execute and return all records lazily for
|
||||
* <code><pre>SELECT * FROM [table]</pre></code>.
|
||||
|
||||
@ -50,7 +50,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@ -2989,6 +2992,20 @@ public interface ResultQuery<R extends Record> extends Query, Iterable<R> {
|
||||
*/
|
||||
<E> List<E> fetch(RecordMapper<? super R, E> mapper) throws DataAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the {@link ForkJoinPool#commonPool()}.
|
||||
*/
|
||||
CompletionStage<Result<R>> fetchAsync();
|
||||
|
||||
/**
|
||||
* Fetch results in a new {@link CompletionStage} that is asynchronously
|
||||
* completed by a task running in the given executor.
|
||||
*/
|
||||
CompletionStage<Result<R>> fetchAsync(Executor executor);
|
||||
|
||||
|
||||
/**
|
||||
* Fetch results asynchronously.
|
||||
* <p>
|
||||
|
||||
@ -61,6 +61,9 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.stream.Stream;
|
||||
@ -320,6 +323,17 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final CompletionStage<Result<R>> fetchAsync() {
|
||||
return CompletableFuture.supplyAsync(this::fetch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompletionStage<Result<R>> fetchAsync(Executor executor) {
|
||||
return CompletableFuture.supplyAsync(this::fetch, executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Stream<R> fetchStream() {
|
||||
return fetchLazy().stream();
|
||||
@ -331,6 +345,7 @@ abstract class AbstractResultQuery<R extends Record> extends AbstractQuery imple
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final Cursor<R> fetchLazy() {
|
||||
return fetchLazy(fetchSize);
|
||||
|
||||
@ -70,6 +70,9 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.annotation.Generated;
|
||||
@ -603,6 +606,47 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(SQL sql) {
|
||||
return resultQuery(sql).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(String sql) {
|
||||
return resultQuery(sql).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(String sql, Object... bindings) {
|
||||
return resultQuery(sql, bindings).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(String sql, QueryPart... parts) {
|
||||
return resultQuery(sql, parts).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, SQL sql) {
|
||||
return resultQuery(sql).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql) {
|
||||
return resultQuery(sql).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql, Object... bindings) {
|
||||
return resultQuery(sql, bindings).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, String sql, QueryPart... parts) {
|
||||
return resultQuery(sql, parts).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Record> fetchStream(SQL sql) {
|
||||
return resultQuery(sql).stream();
|
||||
@ -959,6 +1003,47 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(ResultSet rs) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(ResultSet rs, Field<?>... fields) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, fields));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(ResultSet rs, DataType<?>... types) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, types));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(ResultSet rs, Class<?>... types) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, types));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, Field<?>... fields) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, fields), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, DataType<?>... types) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, types), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionStage<Result<Record>> fetchAsync(Executor executor, ResultSet rs, Class<?>... types) {
|
||||
return CompletableFuture.supplyAsync(() -> fetch(rs, types), executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<Record> fetchStream(ResultSet rs) {
|
||||
return fetchLazy(rs).stream();
|
||||
@ -2920,6 +3005,33 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(ResultQuery<R> query) {
|
||||
final Configuration previous = Utils.getConfiguration(query);
|
||||
|
||||
try {
|
||||
query.attach(configuration());
|
||||
return query.fetchAsync();
|
||||
}
|
||||
finally {
|
||||
query.attach(previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, ResultQuery<R> query) {
|
||||
final Configuration previous = Utils.getConfiguration(query);
|
||||
|
||||
try {
|
||||
query.attach(configuration());
|
||||
return query.fetchAsync(executor);
|
||||
}
|
||||
finally {
|
||||
query.attach(previous);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> Stream<R> fetchStream(ResultQuery<R> query) {
|
||||
final Configuration previous = Utils.getConfiguration(query);
|
||||
@ -2934,6 +3046,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public <R extends Record> Results fetchMany(ResultQuery<R> query) {
|
||||
final Configuration previous = Utils.getConfiguration(query);
|
||||
@ -3117,6 +3230,27 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(Table<R> table) {
|
||||
return selectFrom(table).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(Table<R> table, Condition condition) {
|
||||
return selectFrom(table).where(condition).fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, Table<R> table) {
|
||||
return selectFrom(table).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> CompletionStage<Result<R>> fetchAsync(Executor executor, Table<R> table, Condition condition) {
|
||||
return selectFrom(table).where(condition).fetchAsync(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends Record> Stream<R> fetchStream(Table<R> table) {
|
||||
return fetchStream(table, trueCondition());
|
||||
@ -3128,6 +3262,7 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public <R extends TableRecord<R>> int executeInsert(R record) {
|
||||
InsertQuery<R> insert = insertQuery(record.getTable());
|
||||
|
||||
@ -53,6 +53,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@ -3598,6 +3600,18 @@ class SelectImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,
|
||||
return getDelegate().fetch(mapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final CompletionStage<Result<R>> fetchAsync() {
|
||||
return getDelegate().fetchAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompletionStage<Result<R>> fetchAsync(Executor executor) {
|
||||
return getDelegate().fetchAsync(executor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final org.jooq.FutureResult<R> fetchLater() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user