Polishing
This commit is contained in:
@@ -433,15 +433,6 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
|
||||
boolean readOnly, @Nullable IsolationLevel isolationLevel, Duration lockWaitTimeout)
|
||||
implements io.r2dbc.spi.TransactionDefinition {
|
||||
|
||||
private ExtendedTransactionDefinition(@Nullable String transactionName, boolean readOnly,
|
||||
@Nullable IsolationLevel isolationLevel, Duration lockWaitTimeout) {
|
||||
|
||||
this.transactionName = transactionName;
|
||||
this.readOnly = readOnly;
|
||||
this.isolationLevel = isolationLevel;
|
||||
this.lockWaitTimeout = lockWaitTimeout;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T getAttribute(Option<T> option) {
|
||||
@@ -459,8 +450,8 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
|
||||
if (io.r2dbc.spi.TransactionDefinition.READ_ONLY.equals(option)) {
|
||||
return this.readOnly;
|
||||
}
|
||||
if (io.r2dbc.spi.TransactionDefinition.LOCK_WAIT_TIMEOUT.equals(option)
|
||||
&& !this.lockWaitTimeout.isZero()) {
|
||||
if (io.r2dbc.spi.TransactionDefinition.LOCK_WAIT_TIMEOUT.equals(option) &&
|
||||
!this.lockWaitTimeout.isZero()) {
|
||||
return this.lockWaitTimeout;
|
||||
}
|
||||
return null;
|
||||
@@ -468,7 +459,7 @@ public class R2dbcTransactionManager extends AbstractReactiveTransactionManager
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [transactionName='").append(this.transactionName).append('\'');
|
||||
sb.append(", readOnly=").append(this.readOnly);
|
||||
|
||||
@@ -222,7 +222,7 @@ public interface DatabaseClient extends ConnectionAccessor {
|
||||
* Configure a result mapping {@link Function function} and enter the execution stage.
|
||||
* @param mappingFunction a function that maps from {@link Readable} to the result type
|
||||
* @param <R> the result type
|
||||
* @return a {@link FetchSpec} for configuration what to fetch
|
||||
* @return a {@link RowsFetchSpec} for configuration what to fetch
|
||||
* @since 6.0
|
||||
*/
|
||||
<R> RowsFetchSpec<R> map(Function<? super Readable, R> mappingFunction);
|
||||
@@ -232,12 +232,12 @@ public interface DatabaseClient extends ConnectionAccessor {
|
||||
* @param mappingFunction a function that maps from {@link Row} and {@link RowMetadata}
|
||||
* to the result type
|
||||
* @param <R> the result type
|
||||
* @return a {@link FetchSpec} for configuration what to fetch
|
||||
* @return a {@link RowsFetchSpec} for configuration what to fetch
|
||||
*/
|
||||
<R> RowsFetchSpec<R> map(BiFunction<Row, RowMetadata, R> mappingFunction);
|
||||
|
||||
/**
|
||||
* Perform the SQL call and apply {@link BiFunction function} to the {@link Result}.
|
||||
* Perform the SQL call and apply {@link BiFunction function} to the {@link Result}.
|
||||
* @param mappingFunction a function that maps from {@link Result} into a result publisher
|
||||
* @param <R> the result type
|
||||
* @return a {@link Flux} that emits mapped elements
|
||||
|
||||
@@ -392,24 +392,20 @@ final class DefaultDatabaseClient implements DatabaseClient {
|
||||
return statement;
|
||||
};
|
||||
|
||||
return new ResultFunction(sqlSupplier, statementFunction, this.filterFunction, DefaultDatabaseClient.this.executeFunction);
|
||||
return new ResultFunction(sqlSupplier, statementFunction, this.filterFunction,
|
||||
DefaultDatabaseClient.this.executeFunction);
|
||||
}
|
||||
|
||||
private <T> FetchSpec<T> execute(Supplier<String> sqlSupplier, Function<Result, Publisher<T>> resultAdapter) {
|
||||
ResultFunction resultHandler = getResultFunction(sqlSupplier);
|
||||
|
||||
return new DefaultFetchSpec<>(
|
||||
DefaultDatabaseClient.this,
|
||||
resultHandler,
|
||||
connection -> sumRowsUpdated(resultHandler, connection),
|
||||
resultAdapter);
|
||||
return new DefaultFetchSpec<>(DefaultDatabaseClient.this, resultHandler,
|
||||
connection -> sumRowsUpdated(resultHandler, connection), resultAdapter);
|
||||
}
|
||||
|
||||
private <T> Flux<T> flatMap(Supplier<String> sqlSupplier, Function<Result, Publisher<T>> mappingFunction) {
|
||||
ResultFunction resultHandler = getResultFunction(sqlSupplier);
|
||||
ConnectionFunction<Flux<T>> connectionFunction = new DelegateConnectionFunction<>(resultHandler, cx -> resultHandler
|
||||
.apply(cx)
|
||||
.flatMap(mappingFunction));
|
||||
ConnectionFunction<Flux<T>> connectionFunction = new DelegateConnectionFunction<>(resultHandler,
|
||||
cx -> resultHandler.apply(cx).flatMap(mappingFunction));
|
||||
return inConnectionMany(connectionFunction);
|
||||
}
|
||||
|
||||
@@ -448,8 +444,7 @@ final class DefaultDatabaseClient implements DatabaseClient {
|
||||
|
||||
private void assertNotPreparedOperation() {
|
||||
if (this.sqlSupplier instanceof PreparedOperation<?>) {
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"Cannot add bindings to a PreparedOperation");
|
||||
throw new InvalidDataAccessApiUsageException("Cannot add bindings to a PreparedOperation");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,8 +492,7 @@ final class DefaultDatabaseClient implements DatabaseClient {
|
||||
return this.target;
|
||||
case "close":
|
||||
// Handle close method: suppress, not valid.
|
||||
return Mono.error(
|
||||
new UnsupportedOperationException("Close is not supported!"));
|
||||
return Mono.error(new UnsupportedOperationException("Close is not supported!"));
|
||||
}
|
||||
|
||||
// Invoke method on target Connection.
|
||||
|
||||
Reference in New Issue
Block a user