From ece57a0b2a0e09861bac08c532cef638c31c1044 Mon Sep 17 00:00:00 2001 From: GangCheng Date: Sat, 20 Jan 2024 09:45:22 +0800 Subject: [PATCH] refactor DefaultReactiveMybatisExecutor and ReadableResultWrapper --- .../test/MybatisR2dbcApplicationTests.java | 6 +- .../spring/test/MybatisR2dbcBaseTests.java | 2 +- .../MybatisR2dbcRoutingApplicationTests.java | 2 +- ...MybatisR2dbcXmlConfigApplicationTests.java | 2 +- .../DefaultReactiveMybatisExecutor.java | 58 +++++------------ .../result/ReadableResultWrapper.java | 41 ++++++++++++ .../handler/DefaultReactiveResultHandler.java | 62 +++++++++---------- .../result/handler/ReactiveResultHandler.java | 15 ++--- .../support/MybatisR2dbcBaseTests.java | 4 +- 9 files changed, 99 insertions(+), 93 deletions(-) diff --git a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcApplicationTests.java b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcApplicationTests.java index 9340530..345d6d0 100644 --- a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcApplicationTests.java +++ b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcApplicationTests.java @@ -24,7 +24,7 @@ import org.springframework.transaction.ReactiveTransactionManager; import org.springframework.transaction.reactive.TransactionalOperator; import org.springframework.transaction.support.DefaultTransactionDefinition; -import org.testcontainers.containers.MySQLContainer; +import org.testcontainers.containers.MariaDBContainer; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -38,9 +38,9 @@ public class MybatisR2dbcApplicationTests extends MybatisR2dbcBaseTests { @DynamicPropertySource - static void postgresqlProperties(DynamicPropertyRegistry registry) { + static void configureProperties(DynamicPropertyRegistry registry) { String envDatabaseType = System.getProperty("databaseType", - MySQLContainer.class.getSimpleName() + MariaDBContainer.class.getSimpleName() ); databaseInitializationContainer.keySet() .stream() diff --git a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcBaseTests.java b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcBaseTests.java index a11695f..962efe0 100644 --- a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcBaseTests.java +++ b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcBaseTests.java @@ -99,7 +99,7 @@ void validateTestcontainers() { return; } String envDatabaseType = System.getProperty("databaseType", - MySQLContainer.class.getSimpleName() + MariaDBContainer.class.getSimpleName() ); for (Class aClass : MybatisR2dbcBaseTests.databaseInitializationContainer.keySet()) { if (!aClass.getSimpleName().equalsIgnoreCase(envDatabaseType)) { diff --git a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcRoutingApplicationTests.java b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcRoutingApplicationTests.java index 5496e4e..edff562 100644 --- a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcRoutingApplicationTests.java +++ b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcRoutingApplicationTests.java @@ -56,7 +56,7 @@ public class MybatisR2dbcRoutingApplicationTests extends MybatisR2dbcBaseTests { @DynamicPropertySource - static void postgresqlProperties(DynamicPropertyRegistry registry) { + static void configureProperties(DynamicPropertyRegistry registry) { R2dbcProtocol mysqlR2dbcProtocol = setUp(MySQLContainer.class, false); registry.add("spring.r2dbc.mybatis.routing.definitions[0].name", MySQLContainer.class::getSimpleName); registry.add("spring.r2dbc.mybatis.routing.definitions[0].as-default", () -> Boolean.TRUE); diff --git a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcXmlConfigApplicationTests.java b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcXmlConfigApplicationTests.java index 5818ecd..085bfab 100644 --- a/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcXmlConfigApplicationTests.java +++ b/mybatis-r2dbc-spring/src/test/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/spring/test/MybatisR2dbcXmlConfigApplicationTests.java @@ -36,7 +36,7 @@ public class MybatisR2dbcXmlConfigApplicationTests extends MybatisR2dbcBaseTests { @DynamicPropertySource - static void postgresqlProperties(DynamicPropertyRegistry registry) { + static void configureProperties(DynamicPropertyRegistry registry) { String envDatabaseType = System.getProperty("databaseType", MySQLContainer.class.getSimpleName() ); diff --git a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/DefaultReactiveMybatisExecutor.java b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/DefaultReactiveMybatisExecutor.java index 1685dcd..2186a26 100644 --- a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/DefaultReactiveMybatisExecutor.java +++ b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/DefaultReactiveMybatisExecutor.java @@ -53,7 +53,6 @@ import reactor.core.publisher.Mono; import java.sql.SQLException; -import java.util.Collection; import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -61,13 +60,6 @@ import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.key.KeyGeneratorType.SELECT_KEY_AFTER; import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.key.KeyGeneratorType.SELECT_KEY_BEFORE; import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.key.KeyGeneratorType.SIMPLE_RETURN; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR_BY_INDEX; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR_BY_NAME; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR_BY_INDEX; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR_BY_NAME; -import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.handler.ReactiveResultHandler.DEFERRED; /** * The type Default reactive mybatis executor. @@ -126,17 +118,11 @@ protected Mono doUpdateWithConnection(Connection connection, MappedStat ) .checkpoint("[DefaultReactiveExecutor] SQL: \"" + boundSqlStatement + "\" ") .concatMap(result -> result.map((row, rowMetadata) -> { - ReadableResultWrapper readableResultWrapper = new ReadableResultWrapper<>( - row, - ROW_METADATA_EXTRACTOR, - ROW_METADATA_EXTRACTOR_BY_INDEX, - ROW_METADATA_EXTRACTOR_BY_NAME, - configuration - ); + ReadableResultWrapper readableResultWrapper = ReadableResultWrapper.ofRow(row,configuration); return r2dbcKeyGenerator.processGeneratedKeyResult(readableResultWrapper, parameter); })); } - ReactiveResultHandler reactiveResultHandler = new DefaultReactiveResultHandler(configuration, mappedStatement, boundSql, parameterHandler); + final ReactiveResultHandler reactiveResultHandler = new DefaultReactiveResultHandler(configuration, mappedStatement, boundSql, parameterHandler); boolean anyOutParameterExist = boundSql.getParameterMappings() .stream() .anyMatch(parameterMapping -> @@ -165,15 +151,12 @@ protected Mono doUpdateWithConnection(Connection connection, MappedStat } // output parameters if (segment instanceof Result.OutSegment) { - ReadableResultWrapper readableResultWrapper = new ReadableResultWrapper<>( + ReadableResultWrapper readableResultWrapper = ReadableResultWrapper.ofOutParameters( ((Result.OutSegment) segment).outParameters(), - OUT_PARAMETERS_METADATA_EXTRACTOR, - OUT_PARAMETERS_METADATA_EXTRACTOR_BY_INDEX, - OUT_PARAMETERS_METADATA_EXTRACTOR_BY_NAME, configuration ); - reactiveResultHandler.handleOutputParameters(readableResultWrapper); - return Mono.just(1); + return reactiveResultHandler.handleOutputParameters(readableResultWrapper) + .thenReturn(1); } log.trace("[DoUpdate]Ignore process result's segment : " + segment.getClass()); return Mono.empty(); @@ -208,7 +191,7 @@ protected Flux doQueryWithConnection(Connection connection, MappedStateme StatementHandler handler = configuration.newStatementHandler(null, mappedStatement, parameter, rowBounds, null, null); ParameterHandler parameterHandler = handler.getParameterHandler(); Statement statement = this.createStatementInternal(connection, boundSql, mappedStatement, parameterHandler, rowBounds, false, attribute, r2dbcStatementLog); - ReactiveResultHandler reactiveResultHandler = new DefaultReactiveResultHandler(configuration, mappedStatement, boundSql, parameterHandler); + final ReactiveResultHandler reactiveResultHandler = new DefaultReactiveResultHandler(configuration, mappedStatement, boundSql, parameterHandler); boolean anyOutParameterExist = boundSql.getParameterMappings() .stream() .anyMatch(parameterMapping -> @@ -231,28 +214,22 @@ protected Flux doQueryWithConnection(Connection connection, MappedStateme } // row data if (segment instanceof Result.RowSegment) { - ReadableResultWrapper readableResultWrapper = new ReadableResultWrapper<>( + ReadableResultWrapper readableResultWrapper = ReadableResultWrapper.ofRow( ((Result.RowSegment) segment).row(), - ROW_METADATA_EXTRACTOR, - ROW_METADATA_EXTRACTOR_BY_INDEX, - ROW_METADATA_EXTRACTOR_BY_NAME, configuration ); - return Mono.just((E) reactiveResultHandler.handleResult(readableResultWrapper)); + return reactiveResultHandler.handleResult(readableResultWrapper); } // output parameters if (segment instanceof Result.OutSegment) { - ReadableResultWrapper readableResultWrapper = new ReadableResultWrapper<>( + ReadableResultWrapper readableResultWrapper = ReadableResultWrapper.ofOutParameters( ((Result.OutSegment) segment).outParameters(), - OUT_PARAMETERS_METADATA_EXTRACTOR, - OUT_PARAMETERS_METADATA_EXTRACTOR_BY_INDEX, - OUT_PARAMETERS_METADATA_EXTRACTOR_BY_NAME, configuration ); - return Mono.just(reactiveResultHandler.handleOutputParameters(readableResultWrapper)); + return reactiveResultHandler.handleOutputParameters(readableResultWrapper); } log.trace("[DoQuery]Ignore process result's segment : " + segment.getClass()); - return Mono.empty(); + return Mono.empty(); }); } return result.filter(segment -> segment instanceof Result.Message @@ -262,21 +239,14 @@ protected Flux doQueryWithConnection(Connection connection, MappedStateme if (segment instanceof Result.Message) { return Mono.error(((Result.Message) segment).exception()); } - ReadableResultWrapper readableResultWrapper = new ReadableResultWrapper<>( + ReadableResultWrapper readableResultWrapper = ReadableResultWrapper.ofRow( ((Result.RowSegment) segment).row(), - ROW_METADATA_EXTRACTOR, - ROW_METADATA_EXTRACTOR_BY_INDEX, - ROW_METADATA_EXTRACTOR_BY_NAME, configuration ); - return Mono.just(reactiveResultHandler.handleResult(readableResultWrapper)); + return reactiveResultHandler.handleResult(readableResultWrapper); }); }) - .concatWith(Flux.defer(() -> Flux - .fromIterable((Collection)reactiveResultHandler.getRemainedResults()) - .filter(Objects::nonNull)) - ) - .filter(data -> !Objects.equals(data, DEFERRED)) + .concatWith(Flux.defer(reactiveResultHandler::getRemainedResults)) .doOnCancel(() -> { //clean up reactiveResultHandler reactiveResultHandler.cleanup(); diff --git a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/ReadableResultWrapper.java b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/ReadableResultWrapper.java index 70c995b..e0037d5 100644 --- a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/ReadableResultWrapper.java +++ b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/ReadableResultWrapper.java @@ -38,6 +38,13 @@ import java.util.function.BiFunction; import java.util.function.Function; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR_BY_INDEX; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.OUT_PARAMETERS_METADATA_EXTRACTOR_BY_NAME; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR_BY_INDEX; +import static pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper.Functions.ROW_METADATA_EXTRACTOR_BY_NAME; + /** * The type Row result wrapper. *

@@ -94,6 +101,40 @@ public abstract static class Functions { = (outParameters, name) -> outParameters.getMetadata().getParameterMetadata(name); } + /** + * New result wrapper of row readable. + * + * @param row the row + * @param r2dbcMybatisConfiguration the r2dbc mybatis configuration + * @return the readable result wrapper + */ + public static ReadableResultWrapper ofRow(Row row, R2dbcMybatisConfiguration r2dbcMybatisConfiguration) { + return new ReadableResultWrapper<>( + row, + ROW_METADATA_EXTRACTOR, + ROW_METADATA_EXTRACTOR_BY_INDEX, + ROW_METADATA_EXTRACTOR_BY_NAME, + r2dbcMybatisConfiguration + ); + } + + /** + * New result wrapper of out parameters. + * + * @param outParameters the out parameters + * @param r2dbcMybatisConfiguration the r2dbc mybatis configuration + * @return the readable result wrapper + */ + public static ReadableResultWrapper ofOutParameters(OutParameters outParameters, + R2dbcMybatisConfiguration r2dbcMybatisConfiguration) { + return new ReadableResultWrapper<>( + outParameters, + OUT_PARAMETERS_METADATA_EXTRACTOR, + OUT_PARAMETERS_METADATA_EXTRACTOR_BY_INDEX, + OUT_PARAMETERS_METADATA_EXTRACTOR_BY_NAME, + r2dbcMybatisConfiguration + ); + } private final T readable; private final BiFunction metadataExtractorByIndex; diff --git a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/DefaultReactiveResultHandler.java b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/DefaultReactiveResultHandler.java index 65115b8..c7b8ea9 100644 --- a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/DefaultReactiveResultHandler.java +++ b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/DefaultReactiveResultHandler.java @@ -47,6 +47,8 @@ import pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper; import pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.TypeHandleContext; import pro.chenggang.project.reactive.mybatis.support.r2dbc.support.ProxyInstanceFactory; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; import java.lang.reflect.Constructor; import java.lang.reflect.Parameter; @@ -60,6 +62,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.LongAdder; @@ -120,12 +123,12 @@ public Integer getResultRowTotalCount() { @SuppressWarnings("unchecked") @Override - public T handleResult(ReadableResultWrapper readableResultWrapper) { + public Mono handleResult(ReadableResultWrapper readableResultWrapper) { List resultMaps = mappedStatement.getResultMaps(); int resultMapCount = resultMaps.size(); if (resultMapCount < 1) { - throw new ExecutorException("A query was run and no Result Maps were found for the Mapped Statement '" + mappedStatement.getId() - + "'. It's likely that neither a Result Type nor a Result Map was specified."); + return Mono.error(new ExecutorException("A query was run and no Result Maps were found for the Mapped Statement '" + mappedStatement.getId() + + "'. It's likely that neither a Result Type nor a Result Map was specified.")); } ResultMap resultMap = resultMaps.get(0); if (!resultMap.hasNestedResultMaps()) { @@ -133,57 +136,57 @@ public T handleResult(ReadableResultWrapper readableResu ResultMap discriminatedResultMap = resolveDiscriminatedResultMap(readableResultWrapper, resultMap, null); Object rowValue = getRowValueForSimpleResultMap(readableResultWrapper, discriminatedResultMap, null); totalCount.increment(); - return (T) (rowValue == null ? DEFERRED : rowValue); + return Mono.justOrEmpty((T) rowValue); } catch (SQLException e) { - throw new R2dbcResultException(e); + return Mono.error(new R2dbcResultException(e)); } } try { Object rowValue = handleRowValuesForNestedResultMap(readableResultWrapper, resultMap); totalCount.increment(); - return (T) (rowValue == null ? DEFERRED : rowValue); + return Mono.justOrEmpty((T) rowValue); } catch (SQLException e) { - throw new R2dbcResultException(e); + return Mono.error(new R2dbcResultException(e)); } } @Override - public T handleOutputParameters(ReadableResultWrapper readableResultWrapper) { + public Mono handleOutputParameters(ReadableResultWrapper readableResultWrapper) { final Object parameterObject = parameterHandler.getParameterObject(); final MetaObject metaParam = r2dbcMybatisConfiguration.newMetaObject(parameterObject); final List parameterMappings = boundSql.getParameterMappings(); - TypeHandler outputDelegatedTypeHandler = this.initDelegateTypeHandler(); - try { - for (final ParameterMapping parameterMapping : parameterMappings) { - if (parameterMapping.getMode() == ParameterMode.OUT || parameterMapping.getMode() == ParameterMode.INOUT) { + final TypeHandler outputDelegatedTypeHandler = this.initDelegateTypeHandler(); + return Flux.fromIterable(parameterMappings) + .filter(parameterMapping -> parameterMapping.getMode() == ParameterMode.OUT || parameterMapping.getMode() == ParameterMode.INOUT) + .concatMap(parameterMapping -> { if (ResultSet.class.equals(parameterMapping.getJavaType()) || Row.class.equals(parameterMapping.getJavaType()) || Result.class.equals(parameterMapping.getJavaType())) { - throw new UnsupportedOperationException( + return Mono.error(new UnsupportedOperationException( "Unsupported Java type encountered: '" + parameterMapping.getJavaType() + "' during output parameter mapping." + " To handle multiple rows of output parameters, " + "consider using a query operation rather than an update operation." + - " Receiving output parameters with an update operation is only effective for single-row results."); - } else { + " Receiving output parameters with an update operation is only effective for single-row results.")); + } + try { final TypeHandler typeHandler = parameterMapping.getTypeHandler(); - ((TypeHandleContext) outputDelegatedTypeHandler) - .contextWith(parameterMapping.getJavaType(), typeHandler, readableResultWrapper); + ((TypeHandleContext) outputDelegatedTypeHandler).contextWith(parameterMapping.getJavaType(), typeHandler, readableResultWrapper); Object value = outputDelegatedTypeHandler.getResult(null, parameterMapping.getProperty()); metaParam.setValue(parameterMapping.getProperty(), value); + }catch (SQLException e) { + return Mono.error(new R2dbcResultException(e)); } - } - } - }catch (SQLException e) { - throw new R2dbcResultException(e); - } - return (T) DEFERRED; + return Mono.empty(); + }) + .then(Mono.empty()); } @SuppressWarnings("unchecked") @Override - public List getRemainedResults() { - return (List) this.resultHolder; + public Flux getRemainedResults() { + return (Flux) Flux.fromIterable(this.resultHolder) + .filter(Objects::nonNull); } @Override @@ -238,12 +241,12 @@ private Object handleRowValuesForNestedResultMap(ReadableResultWrapper resultList = resultHandler.getResultList(); if(resultList == null || resultList.isEmpty()){ - return DEFERRED; + return null; } // if result is not ordered , then hold all results for nested result mapping if(!mappedStatement.isResultOrdered()){ this.resultHolder.addAll(resultList); - return DEFERRED; + return null; } // result is ordered,then hold before next nested result mapping @@ -256,7 +259,7 @@ private Object handleRowValuesForNestedResultMap(ReadableResultWrapper readableResultWrapper, ResultMap resultMap, MetaObject metaObject, String parentPrefix, CacheKey parentRowKey, boolean newObject) { @@ -346,9 +349,6 @@ private boolean applyPropertyMappings(ReadableResultWrapper final String property = propertyMapping.getProperty(); if (property == null) { continue; - } else if (value == DEFERRED) { - foundValues = true; - continue; } if (value != null) { foundValues = true; diff --git a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/ReactiveResultHandler.java b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/ReactiveResultHandler.java index 5e1a12d..a4d63fe 100644 --- a/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/ReactiveResultHandler.java +++ b/mybatis-r2dbc/src/main/java/pro/chenggang/project/reactive/mybatis/support/r2dbc/executor/result/handler/ReactiveResultHandler.java @@ -17,8 +17,8 @@ import io.r2dbc.spi.Readable; import pro.chenggang.project.reactive.mybatis.support.r2dbc.executor.result.ReadableResultWrapper; - -import java.util.List; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; /** * The interface Reactive result handler. @@ -29,11 +29,6 @@ */ public interface ReactiveResultHandler { - /** - * deferred object - */ - Object DEFERRED = new Object(); - /** * get result row total count * @@ -48,14 +43,14 @@ public interface ReactiveResultHandler { * @param readableResultWrapper the row result wrapper * @return list */ - T handleResult(ReadableResultWrapper readableResultWrapper); + Mono handleResult(ReadableResultWrapper readableResultWrapper); /** * Handle output parameters. * * @param readableResultWrapper the row result wrapper */ - T handleOutputParameters(ReadableResultWrapper readableResultWrapper); + Mono handleOutputParameters(ReadableResultWrapper readableResultWrapper); /** * get remained result or empty list @@ -63,7 +58,7 @@ public interface ReactiveResultHandler { * @param the type parameter * @return remained results */ - List getRemainedResults(); + Flux getRemainedResults(); /** * Clean up diff --git a/mybatis-r2dbc/src/test/java/pro/chenggang/project/reactive/mybatis/support/MybatisR2dbcBaseTests.java b/mybatis-r2dbc/src/test/java/pro/chenggang/project/reactive/mybatis/support/MybatisR2dbcBaseTests.java index 95c2a9c..ad1b63c 100644 --- a/mybatis-r2dbc/src/test/java/pro/chenggang/project/reactive/mybatis/support/MybatisR2dbcBaseTests.java +++ b/mybatis-r2dbc/src/test/java/pro/chenggang/project/reactive/mybatis/support/MybatisR2dbcBaseTests.java @@ -275,7 +275,7 @@ void validateTestcontainers() { return; } String envDatabaseType = System.getProperty("databaseType", - MySQLContainer.class.getSimpleName() + MariaDBContainer.class.getSimpleName() ); for (Class aClass : MybatisR2dbcBaseTests.databaseInitializationContainer.keySet()) { if (!aClass.getSimpleName().equalsIgnoreCase(envDatabaseType)) { @@ -355,7 +355,7 @@ public MybatisR2dbcTestRunner verifyWith(Function, public void run() { String envDatabaseType = System.getProperty("databaseType", - MySQLContainer.class.getSimpleName() + MariaDBContainer.class.getSimpleName() ); databaseInitializationContainer.keySet() .stream()