1
1
/*
2
- * Copyright 2020-2021 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.
19
19
import org .springframework .data .couchbase .core .ReactiveCouchbaseOperations ;
20
20
import org .springframework .data .couchbase .core .ReactiveFindByQueryOperation ;
21
21
import org .springframework .data .couchbase .core .ReactiveFindByQueryOperation .ReactiveFindByQuery ;
22
+ import org .springframework .data .couchbase .core .ReactiveRemoveByQueryOperation .ReactiveRemoveByQuery ;
22
23
import org .springframework .data .couchbase .core .query .Query ;
23
24
import org .springframework .data .couchbase .repository .query .ReactiveCouchbaseQueryExecution .DeleteExecution ;
24
25
import org .springframework .data .couchbase .repository .query .ReactiveCouchbaseQueryExecution .ResultProcessingExecution ;
41
42
public abstract class AbstractReactiveCouchbaseQuery extends AbstractCouchbaseQueryBase <ReactiveCouchbaseOperations >
42
43
implements RepositoryQuery {
43
44
44
- private final ReactiveFindByQuery <?> findOperationWithProjection ;
45
+ private final ReactiveFindByQuery <?> findOp ;
46
+ private final ReactiveRemoveByQuery <?> removeOp ;
45
47
46
48
/**
47
49
* Creates a new {@link AbstractReactiveCouchbaseQuery} from the given {@link ReactiveCouchbaseQueryMethod} and
@@ -62,9 +64,10 @@ public AbstractReactiveCouchbaseQuery(ReactiveCouchbaseQueryMethod method, React
62
64
63
65
EntityMetadata <?> metadata = method .getEntityInformation ();
64
66
Class <?> type = metadata .getJavaType ();
65
- ReactiveFindByQuery <?> findOp = operations .findByQuery (type );
66
- findOp = (ReactiveFindByQuery <?>) (findOp .inScope (method .getScope ()).inCollection (method .getCollection ()));
67
- this .findOperationWithProjection = findOp ;
67
+ this .findOp = (ReactiveFindByQuery <?>) (operations .findByQuery (type ).inScope (method .getScope ())
68
+ .inCollection (method .getCollection ()));
69
+ this .removeOp = (ReactiveRemoveByQuery <?>) (operations .removeByQuery (type ).inScope (method .getScope ())
70
+ .inCollection (method .getCollection ()));
68
71
}
69
72
70
73
/**
@@ -83,10 +86,8 @@ protected Object doExecute(CouchbaseQueryMethod method, ResultProcessor processo
83
86
// query = applyAnnotatedCollationIfPresent(query, accessor); // not yet implemented
84
87
query = applyQueryMetaAttributesIfPresent (query , typeToRead );
85
88
86
- ReactiveFindByQuery <?> find = findOperationWithProjection ;
87
-
88
89
ReactiveCouchbaseQueryExecution execution = getExecution (accessor ,
89
- new ResultProcessingConverter <>(processor , getOperations (), getInstantiators ()), find );
90
+ new ResultProcessingConverter <>(processor , getOperations (), getInstantiators ()), findOp );
90
91
return execution .execute (query , processor .getReturnedType ().getDomainType (), typeToRead , null );
91
92
}
92
93
@@ -113,7 +114,7 @@ private ReactiveCouchbaseQueryExecution getExecutionToWrap(ParameterAccessor acc
113
114
ReactiveFindByQuery <?> operation ) {
114
115
115
116
if (isDeleteQuery ()) {
116
- return new DeleteExecution (getOperations (), getQueryMethod () );
117
+ return new DeleteExecution (removeOp );
117
118
} else if (isTailable (getQueryMethod ())) {
118
119
return (q , t , r , c ) -> operation .as (r ).matching (q .with (accessor .getPageable ())).all (); // s/b tail() instead of
119
120
// all()
0 commit comments