Spring Data Couchbase

org.springframework.data.couchbase.core
Interface CouchbaseOperations

All Known Implementing Classes:
CouchbaseTemplate

public interface CouchbaseOperations

Defines common operations on the Couchbase data source, most commonly implemented by CouchbaseTemplate.

Author:
Michael Nitschinger

Method Summary
<T> T
execute(BucketCallback<T> action)
          Executes a BucketCallback translating any exceptions as necessary.
 boolean exists(String id)
          Checks if the given document exists.
<T> T
findById(String id, Class<T> entityClass)
          Find an object by its given Id and map it to the corresponding entity.
<T> List<T>
findByView(String design, String view, com.couchbase.client.protocol.views.Query query, Class<T> entityClass)
          Query a View for a list of documents of type T.
 CouchbaseConverter getConverter()
          Returns the underlying CouchbaseConverter.
 void insert(Collection<?> batchToInsert)
          Insert a list of objects.
 void insert(Collection<?> batchToInsert, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Insert a list of objects.
 void insert(Object objectToInsert)
          Insert the given object.
 void insert(Object objectToInsert, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Insert the given object.
 com.couchbase.client.protocol.views.ViewResponse queryView(String design, String view, com.couchbase.client.protocol.views.Query query)
          Query a View with direct access to the ViewResponse.
 void remove(Collection<?> batchToRemove)
          Remove a list of objects from the bucket by id.
 void remove(Collection<?> batchToRemove, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Remove a list of objects from the bucket by id.
 void remove(Object objectToRemove)
          Remove the given object from the bucket by id.
 void remove(Object objectToRemove, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Remove the given object from the bucket by id.
 void save(Collection<?> batchToSave)
          Save a list of objects.
 void save(Collection<?> batchToSave, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Save a list of objects.
 void save(Object objectToSave)
          Save the given object.
 void save(Object objectToSave, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Save the given object.
 void update(Collection<?> batchToUpdate)
          Insert a list of objects.
 void update(Collection<?> batchToUpdate, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Insert a list of objects.
 void update(Object objectToUpdate)
          Update the given object.
 void update(Object objectToUpdate, net.spy.memcached.PersistTo persistTo, net.spy.memcached.ReplicateTo replicateTo)
          Update the given object.
 

Method Detail

save

void save(Object objectToSave)
Save the given object.

When the document already exists (specified by its unique id), then it will be overriden. Otherwise it will be created.

Parameters:
objectToSave - the object to store in the bucket.

save

void save(Object objectToSave,
          net.spy.memcached.PersistTo persistTo,
          net.spy.memcached.ReplicateTo replicateTo)
Save the given object.

When the document already exists (specified by its unique id), then it will be overriden. Otherwise it will be created.

Parameters:
objectToSave - the object to store in the bucket.

save

void save(Collection<?> batchToSave)
Save a list of objects.

When one of the documents already exists (specified by its unique id), then it will be overriden. Otherwise it will be created.

Parameters:
batchToSave - the list of objects to store in the bucket.

save

void save(Collection<?> batchToSave,
          net.spy.memcached.PersistTo persistTo,
          net.spy.memcached.ReplicateTo replicateTo)
Save a list of objects.

When one of the documents already exists (specified by its unique id), then it will be overriden. Otherwise it will be created.

Parameters:
batchToSave - the list of objects to store in the bucket.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

insert

void insert(Object objectToInsert)
Insert the given object.

When the document already exists (specified by its unique id), then it will not be overriden. Use the save(java.lang.Object) method for this task.

Parameters:
objectToInsert - the object to add to the bucket.

insert

void insert(Object objectToInsert,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Insert the given object.

When the document already exists (specified by its unique id), then it will not be overriden. Use the save(java.lang.Object) method for this task.

Parameters:
objectToInsert - the object to add to the bucket.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

insert

void insert(Collection<?> batchToInsert)
Insert a list of objects.

When one of the documents already exists (specified by its unique id), then it will not be overriden. Use the save(java.lang.Object) method for this.

Parameters:
batchToInsert - the list of objects to add to the bucket.

insert

void insert(Collection<?> batchToInsert,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Insert a list of objects.

When one of the documents already exists (specified by its unique id), then it will not be overriden. Use the save(java.lang.Object) method for this.

Parameters:
batchToInsert - the list of objects to add to the bucket.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

update

void update(Object objectToUpdate)
Update the given object.

When the document does not exist (specified by its unique id) it will not be created. Use the save(java.lang.Object) method for this.

Parameters:
objectToUpdate - the object to add to the bucket.

update

void update(Object objectToUpdate,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Update the given object.

When the document does not exist (specified by its unique id) it will not be created. Use the save(java.lang.Object) method for this.

Parameters:
objectToUpdate - the object to add to the bucket.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

update

void update(Collection<?> batchToUpdate)
Insert a list of objects.

If one of the documents does not exist (specified by its unique id), then it will not be created. Use the save(java.lang.Object) method for this.

Parameters:
batchToUpdate - the list of objects to add to the bucket.

update

void update(Collection<?> batchToUpdate,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Insert a list of objects.

If one of the documents does not exist (specified by its unique id), then it will not be created. Use the save(java.lang.Object) method for this.

Parameters:
batchToUpdate - the list of objects to add to the bucket.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

findById

<T> T findById(String id,
               Class<T> entityClass)
Find an object by its given Id and map it to the corresponding entity.

Parameters:
id - the unique ID of the document.
entityClass - the entity to map to.
Returns:
returns the found object or null otherwise.

findByView

<T> List<T> findByView(String design,
                       String view,
                       com.couchbase.client.protocol.views.Query query,
                       Class<T> entityClass)
Query a View for a list of documents of type T.

There is no need to Query.setIncludeDocs(boolean) explicitely, because it will be set to true all the time. It is valid to pass in a empty constructed Query object.

This method does not work with reduced views, because they by design do not contain references to original objects. Use the provided queryView(java.lang.String, java.lang.String, com.couchbase.client.protocol.views.Query) method for more flexibility and direct access.

Parameters:
design - the name of the design document.
view - the name of the viewName.
query - the Query object to customize the viewName query.
entityClass - the entity to map to.
Returns:
the converted collection

queryView

com.couchbase.client.protocol.views.ViewResponse queryView(String design,
                                                           String view,
                                                           com.couchbase.client.protocol.views.Query query)
Query a View with direct access to the ViewResponse.

This method is available to ease the working with views by still wrapping exceptions into the Spring infrastructure.

It is especially needed if you want to run reduced viewName queries, because they can't be mapped onto entities directly.

Parameters:
design - the name of the designDocument document.
view - the name of the viewName.
query - the Query object to customize the viewName query.
Returns:
ViewResponse containing the results of the query.

exists

boolean exists(String id)
Checks if the given document exists.

Parameters:
id - the unique ID of the document.
Returns:
whether the document could be found or not.

remove

void remove(Object objectToRemove)
Remove the given object from the bucket by id.

If the object is a String, it will be treated as the document key directly.

Parameters:
objectToRemove - the Object to remove.

remove

void remove(Object objectToRemove,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Remove the given object from the bucket by id.

If the object is a String, it will be treated as the document key directly.

Parameters:
objectToRemove - the Object to remove.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

remove

void remove(Collection<?> batchToRemove)
Remove a list of objects from the bucket by id.

Parameters:
batchToRemove - the list of Objects to remove.

remove

void remove(Collection<?> batchToRemove,
            net.spy.memcached.PersistTo persistTo,
            net.spy.memcached.ReplicateTo replicateTo)
Remove a list of objects from the bucket by id.

Parameters:
batchToRemove - the list of Objects to remove.
persistTo - the persistence constraint setting.
replicateTo - the replication constraint setting.

execute

<T> T execute(BucketCallback<T> action)
Executes a BucketCallback translating any exceptions as necessary.

Allows for returning a result object, that is a domain object or a collection of domain objects.

Type Parameters:
T - the return type.
Parameters:
action - the action to execute in the callback.
Returns:
the return type.

getConverter

CouchbaseConverter getConverter()
Returns the underlying CouchbaseConverter.

Returns:
CouchbaseConverter.

Spring Data Couchbase

Copyright © 2011-2014–2014 Pivotal Software, Inc.. All rights reserved.