committed by
mikereiche
parent
25e03d13b8
commit
4469cefb9d
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
/*
|
|
||||||
* Copyright 2021-2024 the original author or authors
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
* https://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.
|
|
||||||
*/
|
|
||||||
package com.couchbase.client.java.transactions;
|
|
||||||
|
|
||||||
import com.couchbase.client.core.annotation.Stability;
|
|
||||||
import com.couchbase.client.core.transaction.CoreTransactionAttemptContext;
|
|
||||||
import com.couchbase.client.java.codec.JsonSerializer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To access the ReactiveTransactionAttemptContext held by TransactionAttemptContext
|
|
||||||
*
|
|
||||||
* @author Michael Reiche
|
|
||||||
*/
|
|
||||||
@Stability.Internal
|
|
||||||
public class AttemptContextReactiveAccessor {
|
|
||||||
public static ReactiveTransactionAttemptContext createReactiveTransactionAttemptContext(
|
|
||||||
CoreTransactionAttemptContext core, JsonSerializer jsonSerializer) {
|
|
||||||
return new ReactiveTransactionAttemptContext(core, jsonSerializer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
package org.springframework.data.couchbase.core;
|
package org.springframework.data.couchbase.core;
|
||||||
|
|
||||||
import com.couchbase.client.core.api.query.CoreQueryContext;
|
import com.couchbase.client.core.api.query.CoreQueryContext;
|
||||||
|
import com.couchbase.client.core.api.query.CoreQueryOptions;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@@ -28,13 +29,11 @@ import org.springframework.data.couchbase.core.support.PseudoArgs;
|
|||||||
import org.springframework.data.couchbase.core.support.TemplateUtils;
|
import org.springframework.data.couchbase.core.support.TemplateUtils;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import com.couchbase.client.core.io.CollectionIdentifier;
|
|
||||||
import com.couchbase.client.java.ReactiveScope;
|
import com.couchbase.client.java.ReactiveScope;
|
||||||
import com.couchbase.client.java.codec.JsonSerializer;
|
import com.couchbase.client.java.codec.JsonSerializer;
|
||||||
import com.couchbase.client.java.query.QueryOptions;
|
import com.couchbase.client.java.query.QueryOptions;
|
||||||
import com.couchbase.client.java.query.QueryScanConsistency;
|
import com.couchbase.client.java.query.QueryScanConsistency;
|
||||||
import com.couchbase.client.java.query.ReactiveQueryResult;
|
import com.couchbase.client.java.query.ReactiveQueryResult;
|
||||||
import com.couchbase.client.java.transactions.AttemptContextReactiveAccessor;
|
|
||||||
import com.couchbase.client.java.transactions.TransactionQueryOptions;
|
import com.couchbase.client.java.transactions.TransactionQueryOptions;
|
||||||
import com.couchbase.client.java.transactions.TransactionQueryResult;
|
import com.couchbase.client.java.transactions.TransactionQueryResult;
|
||||||
|
|
||||||
@@ -77,9 +76,9 @@ public class ReactiveFindByQueryOperationSupport implements ReactiveFindByQueryO
|
|||||||
private final ReactiveTemplateSupport support;
|
private final ReactiveTemplateSupport support;
|
||||||
|
|
||||||
ReactiveFindByQuerySupport(final ReactiveCouchbaseTemplate template, final Class<?> domainType,
|
ReactiveFindByQuerySupport(final ReactiveCouchbaseTemplate template, final Class<?> domainType,
|
||||||
final Class<T> returnType, final Query query, final QueryScanConsistency scanConsistency, final String scope,
|
final Class<T> returnType, final Query query, final QueryScanConsistency scanConsistency,
|
||||||
final String collection, final QueryOptions options, final String[] distinctFields, final String[] fields,
|
final String scope, final String collection, final QueryOptions options, final String[] distinctFields,
|
||||||
final ReactiveTemplateSupport support) {
|
final String[] fields, final ReactiveTemplateSupport support) {
|
||||||
Assert.notNull(domainType, "domainType must not be null!");
|
Assert.notNull(domainType, "domainType must not be null!");
|
||||||
Assert.notNull(returnType, "returnType must not be null!");
|
Assert.notNull(returnType, "returnType must not be null!");
|
||||||
this.template = template;
|
this.template = template;
|
||||||
@@ -192,10 +191,16 @@ public class ReactiveFindByQueryOperationSupport implements ReactiveFindByQueryO
|
|||||||
return pArgs.getScope() == null ? clientFactory.getCluster().reactive().query(statement, opts)
|
return pArgs.getScope() == null ? clientFactory.getCluster().reactive().query(statement, opts)
|
||||||
: rs.query(statement, opts);
|
: rs.query(statement, opts);
|
||||||
} else {
|
} else {
|
||||||
TransactionQueryOptions opts = buildTransactionOptions(pArgs.getOptions());
|
TransactionQueryOptions options = buildTransactionOptions(pArgs.getOptions());
|
||||||
JsonSerializer jSer = clientFactory.getCluster().environment().jsonSerializer();
|
JsonSerializer jSer = clientFactory.getCluster().environment().jsonSerializer();
|
||||||
return AttemptContextReactiveAccessor.createReactiveTransactionAttemptContext(s.get().getCore(), jSer)
|
CoreQueryOptions opts = options != null ? options.builder().build() : null;
|
||||||
.query(OptionsBuilder.queryContext(pArgs.getScope(), pArgs.getCollection(), rs.bucketName()) == null ? null : rs, statement, opts);
|
return s.get().getCore()
|
||||||
|
.queryBlocking(statement,
|
||||||
|
pArgs.getScope() == null ? null
|
||||||
|
: CoreQueryContext.of(rs.bucketName(), pArgs.getScope()),
|
||||||
|
opts, false)
|
||||||
|
.map(response -> new TransactionQueryResult(response, jSer));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -255,10 +260,15 @@ public class ReactiveFindByQueryOperationSupport implements ReactiveFindByQueryO
|
|||||||
return pArgs.getScope() == null ? clientFactory.getCluster().reactive().query(statement, opts)
|
return pArgs.getScope() == null ? clientFactory.getCluster().reactive().query(statement, opts)
|
||||||
: rs.query(statement, opts);
|
: rs.query(statement, opts);
|
||||||
} else {
|
} else {
|
||||||
TransactionQueryOptions opts = buildTransactionOptions(pArgs.getOptions());
|
TransactionQueryOptions options = buildTransactionOptions(pArgs.getOptions());
|
||||||
JsonSerializer jSer = clientFactory.getCluster().environment().jsonSerializer();
|
JsonSerializer jSer = clientFactory.getCluster().environment().jsonSerializer();
|
||||||
return AttemptContextReactiveAccessor.createReactiveTransactionAttemptContext(s.get().getCore(), jSer)
|
CoreQueryOptions opts = options != null ? options.builder().build() : null;
|
||||||
.query(OptionsBuilder.queryContext(pArgs.getScope(), pArgs.getCollection(), rs.bucketName()) == null ? null : rs, statement, opts);
|
return s.get().getCore()
|
||||||
|
.queryBlocking(statement,
|
||||||
|
pArgs.getScope() == null ? null
|
||||||
|
: CoreQueryContext.of(rs.bucketName(), pArgs.getScope()),
|
||||||
|
opts, false)
|
||||||
|
.map(response -> new TransactionQueryResult(response, jSer));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.querydsl.couchbase.document;
|
package org.springframework.data.couchbase.querydsl.document;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package com.querydsl.couchbase.document;
|
package org.springframework.data.couchbase.querydsl.document;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -24,8 +24,8 @@ import org.springframework.data.domain.Sort;
|
|||||||
|
|
||||||
import com.querydsl.core.support.QueryMixin;
|
import com.querydsl.core.support.QueryMixin;
|
||||||
import com.querydsl.core.types.OrderSpecifier;
|
import com.querydsl.core.types.OrderSpecifier;
|
||||||
import com.querydsl.couchbase.document.AbstractCouchbaseQueryDSL;
|
import org.springframework.data.couchbase.querydsl.document.AbstractCouchbaseQueryDSL;
|
||||||
import com.querydsl.couchbase.document.CouchbaseDocumentSerializer;
|
import org.springframework.data.couchbase.querydsl.document.CouchbaseDocumentSerializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Michael Reiche
|
* @author Michael Reiche
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.Optional;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.querydsl.couchbase.document.CouchbaseDocumentSerializer;
|
import org.springframework.data.couchbase.querydsl.document.CouchbaseDocumentSerializer;
|
||||||
import org.springframework.data.couchbase.core.convert.CouchbaseConverter;
|
import org.springframework.data.couchbase.core.convert.CouchbaseConverter;
|
||||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
|
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
|
||||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
||||||
|
|||||||
Reference in New Issue
Block a user