Class ReactiveCouchbaseTemplate
java.lang.Object
org.springframework.data.couchbase.core.ReactiveCouchbaseTemplate
- All Implemented Interfaces:
Aware,ApplicationContextAware,ReactiveCouchbaseOperations,ReactiveExistsByIdOperation,ReactiveFindByAnalyticsOperation,ReactiveFindByIdOperation,ReactiveFindByQueryOperation,ReactiveFindFromReplicasByIdOperation,ReactiveFluentCouchbaseOperations,ReactiveInsertByIdOperation,ReactiveMutateInByIdOperation,ReactiveRangeScanOperation,ReactiveRemoveByIdOperation,ReactiveRemoveByQueryOperation,ReactiveReplaceByIdOperation,ReactiveUpsertByIdOperation
public class ReactiveCouchbaseTemplate
extends Object
implements ReactiveCouchbaseOperations, ApplicationContextAware
template class for Reactive Couchbase operations
- Author:
- Michael Nitschinger, Michael Reiche, Jorge Rodriguez Martin, Carlos Espinaco, Tigran Babloyan, Andy Toone
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveExistsByIdOperation
ReactiveExistsByIdOperation.ExistsByIdInCollection, ReactiveExistsByIdOperation.ExistsByIdInScope, ReactiveExistsByIdOperation.ExistsByIdWithOptions, ReactiveExistsByIdOperation.ReactiveExistsById, ReactiveExistsByIdOperation.TerminatingExistsByIdNested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveFindByAnalyticsOperation
ReactiveFindByAnalyticsOperation.FindByAnalyticsConsistentWith<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsInCollection<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsInScope<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsWithConsistency<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsWithOptions<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsWithProjection<T>, ReactiveFindByAnalyticsOperation.FindByAnalyticsWithQuery<T>, ReactiveFindByAnalyticsOperation.ReactiveFindByAnalytics<T>, ReactiveFindByAnalyticsOperation.TerminatingFindByAnalytics<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveFindByIdOperation
ReactiveFindByIdOperation.FindByIdInCollection<T>, ReactiveFindByIdOperation.FindByIdInScope<T>, ReactiveFindByIdOperation.FindByIdWithExpiry<T>, ReactiveFindByIdOperation.FindByIdWithLock<T>, ReactiveFindByIdOperation.FindByIdWithOptions<T>, ReactiveFindByIdOperation.FindByIdWithProjection<T>, ReactiveFindByIdOperation.ReactiveFindById<T>, ReactiveFindByIdOperation.TerminatingFindById<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveFindByQueryOperation
ReactiveFindByQueryOperation.FindByQueryConsistentWith<T>, ReactiveFindByQueryOperation.FindByQueryInCollection<T>, ReactiveFindByQueryOperation.FindByQueryInScope<T>, ReactiveFindByQueryOperation.FindByQueryWithConsistency<T>, ReactiveFindByQueryOperation.FindByQueryWithDistinct<T>, ReactiveFindByQueryOperation.FindByQueryWithOptions<T>, ReactiveFindByQueryOperation.FindByQueryWithProjecting<T>, ReactiveFindByQueryOperation.FindByQueryWithProjection<T>, ReactiveFindByQueryOperation.FindByQueryWithQuery<T>, ReactiveFindByQueryOperation.ReactiveFindByQuery<T>, ReactiveFindByQueryOperation.TerminatingFindByQuery<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveFindFromReplicasByIdOperation
ReactiveFindFromReplicasByIdOperation.FindFromReplicasByIdInCollection<T>, ReactiveFindFromReplicasByIdOperation.FindFromReplicasByIdInScope<T>, ReactiveFindFromReplicasByIdOperation.FindFromReplicasByIdWithOptions<T>, ReactiveFindFromReplicasByIdOperation.ReactiveFindFromReplicasById<T>, ReactiveFindFromReplicasByIdOperation.TerminatingFindFromReplicasById<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveInsertByIdOperation
ReactiveInsertByIdOperation.InsertByIdInCollection<T>, ReactiveInsertByIdOperation.InsertByIdInScope<T>, ReactiveInsertByIdOperation.InsertByIdWithDurability<T>, ReactiveInsertByIdOperation.InsertByIdWithExpiry<T>, ReactiveInsertByIdOperation.InsertByIdWithOptions<T>, ReactiveInsertByIdOperation.ReactiveInsertById<T>, ReactiveInsertByIdOperation.TerminatingInsertById<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveMutateInByIdOperation
ReactiveMutateInByIdOperation.MutateInByIdInCollection<T>, ReactiveMutateInByIdOperation.MutateInByIdInScope<T>, ReactiveMutateInByIdOperation.MutateInByIdWithDurability<T>, ReactiveMutateInByIdOperation.MutateInByIdWithExpiry<T>, ReactiveMutateInByIdOperation.MutateInByIdWithOptions<T>, ReactiveMutateInByIdOperation.MutateInByIdWithPaths<T>, ReactiveMutateInByIdOperation.ReactiveMutateInById<T>, ReactiveMutateInByIdOperation.TerminatingMutateInById<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveRangeScanOperation
ReactiveRangeScanOperation.RangeScanConsistentWith<T>, ReactiveRangeScanOperation.RangeScanInCollection<T>, ReactiveRangeScanOperation.RangeScanInScope<T>, ReactiveRangeScanOperation.RangeScanWithBatchByteLimit<T>, ReactiveRangeScanOperation.RangeScanWithBatchItemLimit<T>, ReactiveRangeScanOperation.RangeScanWithOptions<T>, ReactiveRangeScanOperation.RangeScanWithProjection<T>, ReactiveRangeScanOperation.RangeScanWithSort<T>, ReactiveRangeScanOperation.ReactiveRangeScan<T>, ReactiveRangeScanOperation.TerminatingRangeScan<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveRemoveByIdOperation
ReactiveRemoveByIdOperation.ReactiveRemoveById, ReactiveRemoveByIdOperation.RemoveByIdInCollection, ReactiveRemoveByIdOperation.RemoveByIdInScope, ReactiveRemoveByIdOperation.RemoveByIdWithCas, ReactiveRemoveByIdOperation.RemoveByIdWithDurability, ReactiveRemoveByIdOperation.RemoveByIdWithOptions, ReactiveRemoveByIdOperation.TerminatingRemoveByIdNested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveRemoveByQueryOperation
ReactiveRemoveByQueryOperation.ReactiveRemoveByQuery<T>, ReactiveRemoveByQueryOperation.RemoveByQueryConsistentWith<T>, ReactiveRemoveByQueryOperation.RemoveByQueryInCollection<T>, ReactiveRemoveByQueryOperation.RemoveByQueryInScope<T>, ReactiveRemoveByQueryOperation.RemoveByQueryWithConsistency<T>, ReactiveRemoveByQueryOperation.RemoveByQueryWithOptions<T>, ReactiveRemoveByQueryOperation.RemoveByQueryWithQuery<T>, ReactiveRemoveByQueryOperation.TerminatingRemoveByQuery<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveReplaceByIdOperation
ReactiveReplaceByIdOperation.ReactiveReplaceById<T>, ReactiveReplaceByIdOperation.ReplaceByIdInCollection<T>, ReactiveReplaceByIdOperation.ReplaceByIdInScope<T>, ReactiveReplaceByIdOperation.ReplaceByIdWithDurability<T>, ReactiveReplaceByIdOperation.ReplaceByIdWithExpiry<T>, ReactiveReplaceByIdOperation.ReplaceByIdWithOptions<T>, ReactiveReplaceByIdOperation.TerminatingReplaceById<T>Nested classes/interfaces inherited from interface org.springframework.data.couchbase.core.ReactiveUpsertByIdOperation
ReactiveUpsertByIdOperation.ReactiveUpsertById<T>, ReactiveUpsertByIdOperation.TerminatingUpsertById<T>, ReactiveUpsertByIdOperation.UpsertByIdInCollection<T>, ReactiveUpsertByIdOperation.UpsertByIdInScope<T>, ReactiveUpsertByIdOperation.UpsertByIdWithDurability<T>, ReactiveUpsertByIdOperation.UpsertByIdWithExpiry<T>, ReactiveUpsertByIdOperation.UpsertByIdWithOptions<T> -
Constructor Summary
ConstructorsConstructorDescriptionReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter) ReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter, TranslationService translationService) ReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter, TranslationService translationService, com.couchbase.client.java.query.QueryScanConsistency scanConsistency) -
Method Summary
Modifier and TypeMethodDescription<T> reactor.core.publisher.Mono<Long>Returns the count of documents found by the query.Checks if the document exists in the bucket.existsById(Class<?> domainType) Checks if the document exists in the bucket.findByAnalytics(Class<T> domainType) Queries the analytics service.Loads a document from a bucket.findByQuery(Class<T> domainType) Create the operation for the domainTypefindFromReplicasById(Class<T> domainType) Loads a document from a replica.The name of the bucket used.com.couchbase.client.java.CollectiongetCollection(String collectionName) Provides access to aCollectionon the configuredCouchbaseClientFactory.com.couchbase.client.java.query.QueryScanConsistencyReturns the converter used for this template/operations.Returns the underlying client factory.PseudoArgs<?>The name of the scope used, null if the default scope is used.insertById(Class<T> domainType) Insert using the KV service.mutateInById(Class<T> domainType) Mutate using the KV service.protected RuntimeExceptionTries to convert the givenRuntimeExceptioninto aDataAccessExceptionbut returns the original exception if the conversation failed.Loads a document from a bucket.Removes a document.removeById(Class<?> domainType) Removes a document.removeByQuery(Class<T> domainType) Remove via the query service.replaceById(Class<T> domainType) Replace using the KV service.<T> reactor.core.publisher.Mono<T>Save the entity to couchbase.
If there is no version property on the entity class, and this is in a transaction, use insert.voidsetApplicationContext(ApplicationContext applicationContext) voidsetPseudoArgs(PseudoArgs<?> threadLocalArgs) set the ThreadLocal fieldsupport()upsertById(Class<T> domainType) Upsert using the KV service.
-
Constructor Details
-
ReactiveCouchbaseTemplate
public ReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter) -
ReactiveCouchbaseTemplate
public ReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter, TranslationService translationService) -
ReactiveCouchbaseTemplate
public ReactiveCouchbaseTemplate(CouchbaseClientFactory clientFactory, CouchbaseConverter converter, TranslationService translationService, com.couchbase.client.java.query.QueryScanConsistency scanConsistency)
-
-
Method Details
-
save
Description copied from interface:ReactiveCouchbaseOperationsSave the entity to couchbase.
If there is no version property on the entity class, and this is in a transaction, use insert.
If there is no version property on the entity class, and this is not in a transaction, use upsert.
If there is a version property on the entity class, and it is non-zero, then this is an existing document, use replace.
Otherwise, there is a version property for the entity, but it is zero or null, use insert.- Specified by:
savein interfaceReactiveCouchbaseOperations- Type Parameters:
T- the entity class- Parameters:
entity- the entity to save in couchbasescopeAndCollection- for use by repositories only. these are varargs for the scope and collection.- Returns:
-
count
Description copied from interface:ReactiveCouchbaseOperationsReturns the count of documents found by the query.- Specified by:
countin interfaceReactiveCouchbaseOperations- Returns:
-
findById
Description copied from interface:ReactiveFindByIdOperationLoads a document from a bucket.- Specified by:
findByIdin interfaceReactiveFindByIdOperation- Parameters:
domainType- the entity type to use for the results.
-
existsById
Description copied from interface:ReactiveExistsByIdOperationChecks if the document exists in the bucket.- Specified by:
existsByIdin interfaceReactiveExistsByIdOperation
-
existsById
Description copied from interface:ReactiveExistsByIdOperationChecks if the document exists in the bucket.- Specified by:
existsByIdin interfaceReactiveExistsByIdOperation
-
findByAnalytics
public <T> ReactiveFindByAnalyticsOperation.ReactiveFindByAnalytics<T> findByAnalytics(Class<T> domainType) Description copied from interface:ReactiveFindByAnalyticsOperationQueries the analytics service.- Specified by:
findByAnalyticsin interfaceReactiveFindByAnalyticsOperation- Parameters:
domainType- the entity type to use for the results.
-
findByQuery
Description copied from interface:ReactiveFindByQueryOperationCreate the operation for the domainType- Specified by:
findByQueryin interfaceReactiveFindByQueryOperation- Parameters:
domainType- the entity type to use for the results.
-
findFromReplicasById
public <T> ReactiveFindFromReplicasByIdOperation.ReactiveFindFromReplicasById<T> findFromReplicasById(Class<T> domainType) Description copied from interface:ReactiveFindFromReplicasByIdOperationLoads a document from a replica.- Specified by:
findFromReplicasByIdin interfaceReactiveFindFromReplicasByIdOperation- Parameters:
domainType- the entity type to use for the results.
-
insertById
Description copied from interface:ReactiveInsertByIdOperationInsert using the KV service.- Specified by:
insertByIdin interfaceReactiveInsertByIdOperation- Parameters:
domainType- the entity type to insert.
-
removeById
Description copied from interface:ReactiveRemoveByIdOperationRemoves a document.- Specified by:
removeByIdin interfaceReactiveRemoveByIdOperation
-
removeById
Description copied from interface:ReactiveRemoveByIdOperationRemoves a document.- Specified by:
removeByIdin interfaceReactiveRemoveByIdOperation
-
removeByQuery
public <T> ReactiveRemoveByQueryOperation.ReactiveRemoveByQuery<T> removeByQuery(Class<T> domainType) Description copied from interface:ReactiveRemoveByQueryOperationRemove via the query service.- Specified by:
removeByQueryin interfaceReactiveRemoveByQueryOperation
-
replaceById
Description copied from interface:ReactiveReplaceByIdOperationReplace using the KV service.- Specified by:
replaceByIdin interfaceReactiveReplaceByIdOperation- Parameters:
domainType- the entity type to replace.
-
upsertById
Description copied from interface:ReactiveUpsertByIdOperationUpsert using the KV service.- Specified by:
upsertByIdin interfaceReactiveUpsertByIdOperation- Parameters:
domainType- the entity type to upsert.
-
mutateInById
Description copied from interface:ReactiveMutateInByIdOperationMutate using the KV service.- Specified by:
mutateInByIdin interfaceReactiveMutateInByIdOperation- Parameters:
domainType- the entity type to mutate.
-
rangeScan
Description copied from interface:ReactiveRangeScanOperationLoads a document from a bucket.- Specified by:
rangeScanin interfaceReactiveRangeScanOperation- Parameters:
domainType- the entity type to use for the results.
-
getBucketName
Description copied from interface:ReactiveCouchbaseOperationsThe name of the bucket used.- Specified by:
getBucketNamein interfaceReactiveCouchbaseOperations
-
getScopeName
Description copied from interface:ReactiveCouchbaseOperationsThe name of the scope used, null if the default scope is used.- Specified by:
getScopeNamein interfaceReactiveCouchbaseOperations
-
getCouchbaseClientFactory
Description copied from interface:ReactiveCouchbaseOperationsReturns the underlying client factory.- Specified by:
getCouchbaseClientFactoryin interfaceReactiveCouchbaseOperations
-
getCollection
Provides access to aCollectionon the configuredCouchbaseClientFactory.- Parameters:
collectionName- the name of the collection, if null is passed in the default collection is assumed.- Returns:
- the collection instance.
-
getConverter
Description copied from interface:ReactiveCouchbaseOperationsReturns the converter used for this template/operations.- Specified by:
getConverterin interfaceReactiveCouchbaseOperations
-
support
-
potentiallyConvertRuntimeException
Tries to convert the givenRuntimeExceptioninto aDataAccessExceptionbut returns the original exception if the conversation failed. Thus allows safe re-throwing of the return value.- Parameters:
ex- the exception to translate
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
getPseudoArgs
- Returns:
- the pseudoArgs from the ThreadLocal field
-
setPseudoArgs
set the ThreadLocal field -
getConsistency
public com.couchbase.client.java.query.QueryScanConsistency getConsistency()- Specified by:
getConsistencyin interfaceReactiveCouchbaseOperations- Returns:
- the default consistency to use for queries
-