[jOOQ/jOOQ#3185] Let ResultQuery<R>, InsertResultStep<R>, UpdateResultStep<R>, DeleteResultStep<R> extend Fetchable<R>
This commit is contained in:
parent
6c9f80d710
commit
416f9cc088
@ -37,23 +37,6 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.TooManyRowsException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This type is used for the {@link Delete}'s DSL API.
|
||||
* <p>
|
||||
@ -93,56 +76,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface DeleteResultStep<R extends Record> extends Delete<R> {
|
||||
|
||||
/**
|
||||
* The result holding returned values as specified by the
|
||||
* {@link DeleteReturningStep}.
|
||||
*
|
||||
* @return The returned values as specified by the
|
||||
* {@link DeleteReturningStep}. Note:
|
||||
* <ul>
|
||||
* <li>Not all databases / JDBC drivers support returning several
|
||||
* values on multi-row inserts!</li>
|
||||
* <li>This may return an empty <code>Result</code> in case jOOQ
|
||||
* could not retrieve any generated keys from the JDBC driver.</li>
|
||||
* </ul>
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @see DeleteQuery#getReturnedRecords()
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ FIREBIRD, MARIADB, POSTGRES })
|
||||
Result<R> fetch() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link DeleteReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link DeleteReturningStep}. This may return <code>null</code> in
|
||||
* case jOOQ could not retrieve any generated keys from the JDBC
|
||||
* driver.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see DeleteQuery#getReturnedRecord()
|
||||
*/
|
||||
@Nullable
|
||||
@Support({ FIREBIRD, MARIADB, POSTGRES })
|
||||
R fetchOne() throws DataAccessException, TooManyRowsException;
|
||||
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link DeleteReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link DeleteReturningStep}
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see DeleteQuery#getReturnedRecord()
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ FIREBIRD, MARIADB, POSTGRES })
|
||||
Optional<R> fetchOptional() throws DataAccessException, TooManyRowsException;
|
||||
public interface DeleteResultStep<R extends Record> extends Delete<R>, Fetchable<R> {
|
||||
|
||||
}
|
||||
|
||||
4151
jOOQ/src/main/java/org/jooq/Fetchable.java
Normal file
4151
jOOQ/src/main/java/org/jooq/Fetchable.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,14 +37,6 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.TooManyRowsException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This type is used for the {@link Insert}'s DSL API.
|
||||
* <p>
|
||||
@ -95,56 +87,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface InsertResultStep<R extends Record> extends Insert<R> {
|
||||
|
||||
/**
|
||||
* The result holding returned values as specified by the
|
||||
* {@link InsertReturningStep}.
|
||||
*
|
||||
* @return The returned values as specified by the
|
||||
* {@link InsertReturningStep}. Note:
|
||||
* <ul>
|
||||
* <li>Not all databases / JDBC drivers support returning several
|
||||
* values on multi-row inserts!</li><li>This may return an empty
|
||||
* <code>Result</code> in case jOOQ could not retrieve any generated
|
||||
* keys from the JDBC driver.</li>
|
||||
* </ul>
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @see InsertQuery#getReturnedRecords()
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
Result<R> fetch() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link InsertReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link InsertReturningStep}. This may return <code>null</code> in
|
||||
* case jOOQ could not retrieve any generated keys from the JDBC
|
||||
* driver.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see InsertQuery#getReturnedRecord()
|
||||
*/
|
||||
@Nullable
|
||||
@Support
|
||||
R fetchOne() throws DataAccessException, TooManyRowsException;
|
||||
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link InsertReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link InsertReturningStep}
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see InsertQuery#getReturnedRecord()
|
||||
*/
|
||||
@NotNull
|
||||
@Support
|
||||
Optional<R> fetchOptional() throws DataAccessException, TooManyRowsException;
|
||||
public interface InsertResultStep<R extends Record> extends Insert<R>, Fetchable<R> {
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -37,22 +37,6 @@
|
||||
*/
|
||||
package org.jooq;
|
||||
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.exception.TooManyRowsException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* This type is used for the {@link Update}'s DSL API.
|
||||
* <p>
|
||||
@ -95,56 +79,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public interface UpdateResultStep<R extends Record> extends Update<R> {
|
||||
|
||||
/**
|
||||
* The result holding returned values as specified by the
|
||||
* {@link UpdateReturningStep}.
|
||||
*
|
||||
* @return The returned values as specified by the
|
||||
* {@link UpdateReturningStep}. Note:
|
||||
* <ul>
|
||||
* <li>Not all databases / JDBC drivers support returning several
|
||||
* values on multi-row inserts!</li><li>This may return an empty
|
||||
* <code>Result</code> in case jOOQ could not retrieve any generated
|
||||
* keys from the JDBC driver.</li>
|
||||
* </ul>
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @see UpdateQuery#getReturnedRecords()
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
Result<R> fetch() throws DataAccessException;
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link UpdateReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link UpdateReturningStep}. This may return <code>null</code> in
|
||||
* case jOOQ could not retrieve any generated keys from the JDBC
|
||||
* driver.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see UpdateQuery#getReturnedRecord()
|
||||
*/
|
||||
@Nullable
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
R fetchOne() throws DataAccessException, TooManyRowsException;
|
||||
|
||||
|
||||
/**
|
||||
* The record holding returned values as specified by the
|
||||
* {@link UpdateReturningStep}.
|
||||
*
|
||||
* @return The returned value as specified by the
|
||||
* {@link UpdateReturningStep}.
|
||||
* @throws DataAccessException if something went wrong executing the query
|
||||
* @throws TooManyRowsException if the query returned more than one record
|
||||
* @see UpdateQuery#getReturnedRecord()
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ FIREBIRD, POSTGRES })
|
||||
Optional<R> fetchOptional() throws DataAccessException, TooManyRowsException;
|
||||
public interface UpdateResultStep<R extends Record> extends Update<R>, Fetchable<R> {
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -46,12 +46,15 @@ import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.conf.ParamType;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractDelegatingQuery<Q extends Query> extends AbstractQueryPart implements Query {
|
||||
abstract class AbstractDelegatingQuery<R extends Record, Q extends Query>
|
||||
extends AbstractFetchable<R>
|
||||
implements Query {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -39,12 +39,16 @@ package org.jooq.impl;
|
||||
|
||||
// ...
|
||||
|
||||
import org.jooq.Fetchable;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RowCountQuery;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractDelegatingRowCountQuery<Q extends RowCountQuery> extends AbstractDelegatingQuery<Q> implements RowCountQuery {
|
||||
abstract class AbstractDelegatingRowCountQuery<R extends Record, Q extends RowCountQuery>
|
||||
extends AbstractDelegatingQuery<R, Q>
|
||||
implements RowCountQuery, Fetchable<R> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
1212
jOOQ/src/main/java/org/jooq/impl/AbstractFetchable.java
Normal file
1212
jOOQ/src/main/java/org/jooq/impl/AbstractFetchable.java
Normal file
File diff suppressed because it is too large
Load Diff
@ -73,6 +73,7 @@ import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Param;
|
||||
import org.jooq.Query;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RenderContext;
|
||||
import org.jooq.Select;
|
||||
import org.jooq.conf.ParamType;
|
||||
@ -88,7 +89,7 @@ import org.jooq.tools.JooqLogger;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractQuery extends AbstractQueryPart implements Query {
|
||||
abstract class AbstractQuery<R extends Record> extends AbstractFetchable<R> implements Query {
|
||||
|
||||
private static final long serialVersionUID = -8046199737354507547L;
|
||||
private static final JooqLogger log = JooqLogger.getLogger(AbstractQuery.class);
|
||||
|
||||
@ -1069,10 +1069,10 @@ abstract class AbstractRecord extends AbstractStore implements Record {
|
||||
try {
|
||||
switch (format.recordFormat()) {
|
||||
case ARRAY:
|
||||
AbstractCursor.formatJSONArray0(this, fields, format, 0, writer);
|
||||
AbstractResult.formatJSONArray0(this, fields, format, 0, writer);
|
||||
break;
|
||||
case OBJECT:
|
||||
AbstractCursor.formatJSONMap0(this, fields, format, 0, writer);
|
||||
AbstractResult.formatJSONMap0(this, fields, format, 0, writer);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Format not supported: " + format);
|
||||
@ -1092,7 +1092,7 @@ abstract class AbstractRecord extends AbstractStore implements Record {
|
||||
log.debug("XMLFormat.header currently not supported for Record.formatXML()");
|
||||
|
||||
try {
|
||||
AbstractCursor.formatXMLRecord(writer, format, 0, this, fields);
|
||||
AbstractResult.formatXMLRecord(writer, format, 0, this, fields);
|
||||
}
|
||||
catch (java.io.IOException e) {
|
||||
throw new IOException("Exception while writing XML", e);
|
||||
|
||||
1441
jOOQ/src/main/java/org/jooq/impl/AbstractResult.java
Normal file
1441
jOOQ/src/main/java/org/jooq/impl/AbstractResult.java
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -38,12 +38,13 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RowCountQuery;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
abstract class AbstractRowCountQuery extends AbstractQuery implements RowCountQuery {
|
||||
abstract class AbstractRowCountQuery extends AbstractQuery<Record> implements RowCountQuery {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -65,27 +65,16 @@ import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import java.util.Spliterator;
|
||||
import java.util.Spliterators;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
import org.jooq.BindingGetResultSetContext;
|
||||
import org.jooq.Cursor;
|
||||
import org.jooq.ExecuteContext;
|
||||
import org.jooq.ExecuteListener;
|
||||
import org.jooq.Field;
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.RecordHandler;
|
||||
import org.jooq.RecordMapper;
|
||||
import org.jooq.Result;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.exception.ControlFlowSignal;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.jdbc.JDBC41ResultSet;
|
||||
@ -94,7 +83,7 @@ import org.jooq.tools.jdbc.JDBCUtils;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class CursorImpl<R extends Record> extends AbstractCursor<R> implements Cursor<R> {
|
||||
final class CursorImpl<R extends Record> extends AbstractCursor<R> {
|
||||
|
||||
private static final JooqLogger log = JooqLogger.getLogger(CursorImpl.class);
|
||||
|
||||
@ -214,127 +203,6 @@ final class CursorImpl<R extends Record> extends AbstractCursor<R> implements Cu
|
||||
return iterator;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Stream<R> stream() {
|
||||
return StreamSupport.stream(
|
||||
Spliterators.spliteratorUnknownSize(
|
||||
iterator(),
|
||||
Spliterator.ORDERED | Spliterator.NONNULL
|
||||
),
|
||||
false
|
||||
).onClose(() -> close());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <X, A> X collect(Collector<? super R, A, X> collector) {
|
||||
return stream().collect(collector);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean hasNext() {
|
||||
return iterator().hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Result<R> fetch() {
|
||||
return fetch(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final R fetchOne() {
|
||||
return fetchNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final <E> E fetchOne(RecordMapper<? super R, E> mapper) {
|
||||
return fetchNext(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final <H extends RecordHandler<? super R>> H fetchOneInto(H handler) {
|
||||
return fetchNextInto(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final <Z extends Record> Z fetchOneInto(Table<Z> table) {
|
||||
return fetchNextInto(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public final <E> E fetchOneInto(Class<? extends E> type) {
|
||||
return fetchNextInto(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final R fetchNext() {
|
||||
Result<R> result = fetch(1);
|
||||
|
||||
if (result.size() == 1) {
|
||||
return result.get(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public Optional<R> fetchOptional() {
|
||||
return fetchNextOptional();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <E> Optional<E> fetchOptional(RecordMapper<? super R, E> mapper) {
|
||||
return fetchNextOptional(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <E> Optional<E> fetchOptionalInto(Class<? extends E> type) {
|
||||
return fetchNextOptionalInto(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public <Z extends Record> Optional<Z> fetchOptionalInto(Table<Z> table) {
|
||||
return fetchNextOptionalInto(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Optional<R> fetchNextOptional() {
|
||||
return Optional.ofNullable(fetchNext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> Optional<E> fetchNextOptional(RecordMapper<? super R, E> mapper) {
|
||||
return Optional.ofNullable(fetchNext(mapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> Optional<E> fetchNextOptionalInto(Class<? extends E> type) {
|
||||
return Optional.ofNullable(fetchNextInto(type));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <Z extends Record> Optional<Z> fetchNextOptionalInto(Table<Z> table) {
|
||||
return Optional.ofNullable(fetchNextInto(table));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Result<R> fetch(int number) {
|
||||
return fetchNext(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Result<R> fetchNext(int number) {
|
||||
// [#1157] This invokes listener.fetchStart(ctx), which has to be called
|
||||
@ -354,53 +222,6 @@ final class CursorImpl<R extends Record> extends AbstractCursor<R> implements Cu
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <H extends RecordHandler<? super R>> H fetchNextInto(H handler) {
|
||||
handler.next(fetchNext());
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <H extends RecordHandler<? super R>> H fetchInto(H handler) {
|
||||
while (hasNext()) {
|
||||
fetchNextInto(handler);
|
||||
}
|
||||
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> E fetchNext(RecordMapper<? super R, E> mapper) {
|
||||
R record = fetchNext();
|
||||
return record == null ? null : mapper.map(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> List<E> fetch(RecordMapper<? super R, E> mapper) {
|
||||
return fetch().map(mapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> E fetchNextInto(Class<? extends E> clazz) {
|
||||
R record = fetchNext();
|
||||
return record == null ? null : record.into(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <E> List<E> fetchInto(Class<? extends E> clazz) {
|
||||
return fetch().into(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <Z extends Record> Z fetchNextInto(Table<Z> table) {
|
||||
return fetchNext().into(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <Z extends Record> Result<Z> fetchInto(Table<Z> table) {
|
||||
return fetch().into(table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void close() {
|
||||
JDBCUtils.safeClose(rs);
|
||||
|
||||
@ -93,7 +93,7 @@ import org.jooq.TableLike;
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final class DeleteImpl<R extends Record>
|
||||
extends AbstractDelegatingRowCountQuery<DeleteQueryImpl<R>>
|
||||
extends AbstractDelegatingRowCountQuery<R, DeleteQueryImpl<R>>
|
||||
implements
|
||||
|
||||
// Cascading interface implementations for Delete behaviour
|
||||
@ -519,17 +519,4 @@ final class DeleteImpl<R extends Record>
|
||||
getDelegate().execute();
|
||||
return returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final R fetchOne() {
|
||||
getDelegate().execute();
|
||||
return filterOne(returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Optional<R> fetchOptional() {
|
||||
return Optional.ofNullable(fetchOne());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ import org.jooq.UniqueKey;
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final class InsertImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>
|
||||
extends AbstractDelegatingRowCountQuery<InsertQuery<R>>
|
||||
extends AbstractDelegatingRowCountQuery<R, InsertQuery<R>>
|
||||
implements
|
||||
|
||||
// Cascading interface implementations for Insert behaviour
|
||||
@ -1562,17 +1562,4 @@ final class InsertImpl<R extends Record, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10
|
||||
getDelegate().execute();
|
||||
return returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final R fetchOne() {
|
||||
getDelegate().execute();
|
||||
return filterOne(returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Optional<R> fetchOptional() {
|
||||
return Optional.ofNullable(fetchOne());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
92
jOOQ/src/main/java/org/jooq/impl/ResultAsCursor.java
Normal file
92
jOOQ/src/main/java/org/jooq/impl/ResultAsCursor.java
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Result;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ResultAsCursor<R extends Record> extends AbstractCursor<R> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 3711590697891578695L;
|
||||
private final Result<R> result;
|
||||
private int index;
|
||||
|
||||
ResultAsCursor(Result<R> result) {
|
||||
super(result.configuration(), (AbstractRow) result.fieldsRow());
|
||||
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Iterator<R> iterator() {
|
||||
return result.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Result<R> fetchNext(int number) {
|
||||
Result<R> r = new ResultImpl<R>(configuration, fields);
|
||||
|
||||
for (int i = 0; i < number && i + index < result.size(); i++)
|
||||
r.add(result.get(i + index));
|
||||
|
||||
index += number;
|
||||
return r;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final ResultSet resultSet() {
|
||||
return result.intoResultSet();
|
||||
}
|
||||
}
|
||||
@ -101,7 +101,7 @@ import org.jooq.tools.jdbc.MockResultSet;
|
||||
* @author Ivan Dugic
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked" })
|
||||
final class ResultImpl<R extends Record> extends AbstractCursor<R> implements Result<R> {
|
||||
final class ResultImpl<R extends Record> extends AbstractResult<R> implements Result<R> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -3168,7 +3168,7 @@ final class Tools {
|
||||
if (select instanceof SelectQueryImpl)
|
||||
return (SelectQueryImpl<R>) select;
|
||||
else if (select instanceof AbstractDelegatingQuery)
|
||||
return ((AbstractDelegatingQuery<SelectQueryImpl<R>>) select).getDelegate();
|
||||
return ((AbstractDelegatingQuery<R, SelectQueryImpl<R>>) select).getDelegate();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ import org.jooq.UpdateWhereStep;
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
final class UpdateImpl<R extends Record>
|
||||
extends AbstractDelegatingRowCountQuery<UpdateQuery<R>>
|
||||
extends AbstractDelegatingRowCountQuery<R, UpdateQuery<R>>
|
||||
implements
|
||||
|
||||
// Cascading interface implementations for Update behaviour
|
||||
@ -866,17 +866,4 @@ final class UpdateImpl<R extends Record>
|
||||
getDelegate().execute();
|
||||
return returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final R fetchOne() {
|
||||
getDelegate().execute();
|
||||
return filterOne(returningResult ? (Result<R>) getDelegate().getResult() : getDelegate().getReturnedRecords());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final Optional<R> fetchOptional() {
|
||||
return Optional.ofNullable(fetchOne());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user