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.TerminatingExistsById
Nested 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.TerminatingRemoveById
Nested 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
ConstructorDescriptionReactiveCouchbaseTemplate
(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.Collection
getCollection
(String collectionName) Provides access to aCollection
on the configuredCouchbaseClientFactory
.com.couchbase.client.java.query.QueryScanConsistency
Returns 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 RuntimeException
Tries to convert the givenRuntimeException
into aDataAccessException
but 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.void
setApplicationContext
(ApplicationContext applicationContext) void
setPseudoArgs
(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:ReactiveCouchbaseOperations
Save 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:
save
in 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:ReactiveCouchbaseOperations
Returns the count of documents found by the query.- Specified by:
count
in interfaceReactiveCouchbaseOperations
- Returns:
-
findById
Description copied from interface:ReactiveFindByIdOperation
Loads a document from a bucket.- Specified by:
findById
in interfaceReactiveFindByIdOperation
- Parameters:
domainType
- the entity type to use for the results.
-
existsById
Description copied from interface:ReactiveExistsByIdOperation
Checks if the document exists in the bucket.- Specified by:
existsById
in interfaceReactiveExistsByIdOperation
-
existsById
Description copied from interface:ReactiveExistsByIdOperation
Checks if the document exists in the bucket.- Specified by:
existsById
in interfaceReactiveExistsByIdOperation
-
findByAnalytics
public <T> ReactiveFindByAnalyticsOperation.ReactiveFindByAnalytics<T> findByAnalytics(Class<T> domainType) Description copied from interface:ReactiveFindByAnalyticsOperation
Queries the analytics service.- Specified by:
findByAnalytics
in interfaceReactiveFindByAnalyticsOperation
- Parameters:
domainType
- the entity type to use for the results.
-
findByQuery
Description copied from interface:ReactiveFindByQueryOperation
Create the operation for the domainType- Specified by:
findByQuery
in 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:ReactiveFindFromReplicasByIdOperation
Loads a document from a replica.- Specified by:
findFromReplicasById
in interfaceReactiveFindFromReplicasByIdOperation
- Parameters:
domainType
- the entity type to use for the results.
-
insertById
Description copied from interface:ReactiveInsertByIdOperation
Insert using the KV service.- Specified by:
insertById
in interfaceReactiveInsertByIdOperation
- Parameters:
domainType
- the entity type to insert.
-
removeById
Description copied from interface:ReactiveRemoveByIdOperation
Removes a document.- Specified by:
removeById
in interfaceReactiveRemoveByIdOperation
-
removeById
Description copied from interface:ReactiveRemoveByIdOperation
Removes a document.- Specified by:
removeById
in interfaceReactiveRemoveByIdOperation
-
removeByQuery
public <T> ReactiveRemoveByQueryOperation.ReactiveRemoveByQuery<T> removeByQuery(Class<T> domainType) Description copied from interface:ReactiveRemoveByQueryOperation
Remove via the query service.- Specified by:
removeByQuery
in interfaceReactiveRemoveByQueryOperation
-
replaceById
Description copied from interface:ReactiveReplaceByIdOperation
Replace using the KV service.- Specified by:
replaceById
in interfaceReactiveReplaceByIdOperation
- Parameters:
domainType
- the entity type to replace.
-
upsertById
Description copied from interface:ReactiveUpsertByIdOperation
Upsert using the KV service.- Specified by:
upsertById
in interfaceReactiveUpsertByIdOperation
- Parameters:
domainType
- the entity type to upsert.
-
mutateInById
Description copied from interface:ReactiveMutateInByIdOperation
Mutate using the KV service.- Specified by:
mutateInById
in interfaceReactiveMutateInByIdOperation
- Parameters:
domainType
- the entity type to mutate.
-
rangeScan
Description copied from interface:ReactiveRangeScanOperation
Loads a document from a bucket.- Specified by:
rangeScan
in interfaceReactiveRangeScanOperation
- Parameters:
domainType
- the entity type to use for the results.
-
getBucketName
Description copied from interface:ReactiveCouchbaseOperations
The name of the bucket used.- Specified by:
getBucketName
in interfaceReactiveCouchbaseOperations
-
getScopeName
Description copied from interface:ReactiveCouchbaseOperations
The name of the scope used, null if the default scope is used.- Specified by:
getScopeName
in interfaceReactiveCouchbaseOperations
-
getCouchbaseClientFactory
Description copied from interface:ReactiveCouchbaseOperations
Returns the underlying client factory.- Specified by:
getCouchbaseClientFactory
in interfaceReactiveCouchbaseOperations
-
getCollection
Provides access to aCollection
on 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:ReactiveCouchbaseOperations
Returns the converter used for this template/operations.- Specified by:
getConverter
in interfaceReactiveCouchbaseOperations
-
support
-
potentiallyConvertRuntimeException
Tries to convert the givenRuntimeException
into aDataAccessException
but 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:
setApplicationContext
in 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:
getConsistency
in interfaceReactiveCouchbaseOperations
- Returns:
- the default consistency to use for queries
-