|
1 | 1 | /*
|
2 |
| - * Copyright 2020 the original author or authors |
| 2 | + * Copyright 2020-2022 the original author or authors |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 | import reactor.core.publisher.Flux;
|
19 | 19 | import reactor.core.publisher.Mono;
|
20 | 20 |
|
| 21 | +import org.reactivestreams.Publisher; |
21 | 22 | import org.springframework.data.couchbase.core.CouchbaseOperations;
|
22 | 23 | import org.springframework.data.couchbase.core.ExecutableFindByQueryOperation.ExecutableFindByQuery;
|
23 | 24 | import org.springframework.data.couchbase.core.query.Query;
|
@@ -108,15 +109,16 @@ EntityInstantiators getInstantiators() {
|
108 | 109 | * @see org.springframework.data.repository.query.RepositoryQuery#execute(java.lang.Object[])
|
109 | 110 | */
|
110 | 111 | public Object execute(Object[] parameters) {
|
111 |
| - |
112 | 112 | ReactiveCouchbaseParameterAccessor accessor = new ReactiveCouchbaseParameterAccessor(getQueryMethod(), parameters);
|
113 |
| - |
114 |
| - Object result = accessor.resolveParameters().map(this::executeDeferred); |
115 |
| - return ((Mono<Object>) result).block() ; |
| 113 | + return method.hasReactiveWrapperParameter() ? accessor.resolveParameters().flatMapMany(this::executeDeferred) |
| 114 | + : execute(accessor); |
116 | 115 | }
|
117 | 116 |
|
118 |
| - private Object executeDeferred(ReactiveCouchbaseParameterAccessor parameterAccessor) { |
119 |
| - return execute(parameterAccessor); |
| 117 | + private Publisher<Object> executeDeferred(ReactiveCouchbaseParameterAccessor parameterAccessor) { |
| 118 | + if (getQueryMethod().isCollectionQuery()) { |
| 119 | + return Flux.defer(() -> (Publisher<Object>) execute(parameterAccessor)); |
| 120 | + } |
| 121 | + return Mono.defer(() -> (Mono<Object>) execute(parameterAccessor)); |
120 | 122 | }
|
121 | 123 |
|
122 | 124 | private Object execute(ParametersParameterAccessor parameterAccessor) {
|
|
0 commit comments