次の方法で共有


CosmosOperations Interface

public interface CosmosOperations

Interface for cosmosDB operations

Method Summary

Modifier and Type Method and Description
abstract void <S,T>deleteEntities(CosmosEntityInformation<T,?> information, Iterable<S> entities)

Delete using a list of entities with bulk

abstract Iterable<S> <S,T>insertAll(CosmosEntityInformation<T,?> information, Iterable<S> entities)

Insert items using bulk operations.

abstract Iterable<T> <T,ID>findByIds(Iterable<ID> ids, Class<T> domainType, String containerName)

Find by ids

abstract long count(CosmosQuery query, String containerName)

Count

abstract long count(SqlQuerySpec querySpec, String containerName)

Count

abstract long count(String containerName)

Count

abstract CosmosContainerProperties createContainerIfNotExists(CosmosEntityInformation<?,?> information)

Creates container if not exists

abstract Iterable<T> delete(CosmosQuery query, Class<T> domainType, String containerName)

Delete items matching query.

abstract void deleteAll(String containerName, Class<?> domainType)

Delete all items in a container.

abstract void deleteById(String containerName, Object id, PartitionKey partitionKey)

Delete an item by id

abstract void deleteContainer(String containerName)

Delete container

abstract void deleteEntity(String containerName, T entity)

Delete using entity

abstract Boolean exists(CosmosQuery query, Class<T> domainType, String containerName)

Exists

abstract Iterable<T> find(CosmosQuery query, Class<T> domainType, String containerName)

Find query

abstract Iterable<T> findAll(Class<T> domainType)

Find the DocumentQuery, find all the items specified by domain type.

abstract org.springframework.data.domain.Page<T> findAll(Pageable pageable, Class<T> domainType, String containerName)

Find all items in a given container with partition key

abstract Iterable<T> findAll(PartitionKey partitionKey, Class<T> domainType)

Find the DocumentQuery, find all the items specified by domain type in the given container.

abstract Iterable<T> findAll(String containerName, Class<T> domainType)

Find the DocumentQuery, find all the items specified by domain type in the given container.

abstract T findById(Object id, Class<T> domainType)

Finds item by id

abstract T findById(Object id, Class<T> domainType, PartitionKey partitionKey)

Finds item by id

abstract T findById(String containerName, Object id, Class<T> domainType)

Finds item by id

abstract String getContainerName(Class<?> domainType)

To get container name by domainType

abstract CosmosContainerProperties getContainerProperties(String containerName)

Get properties for specified container

abstract MappingCosmosConverter getConverter()

To get converter

abstract T insert(String containerName, T objectToSave)

Inserts item

abstract T insert(String containerName, T objectToSave, PartitionKey partitionKey)

Inserts item

abstract T insert(T objectToSave, PartitionKey partitionKey)

Inserts item

abstract org.springframework.data.domain.Page<T> paginationQuery(CosmosQuery query, Class<T> domainType, String containerName)

Pagination query

abstract T patch(Object id, PartitionKey partitionKey, Class<T> domainType, CosmosPatchOperations patchOperations)

patches item

abstract T patch(Object id, PartitionKey partitionKey, Class<T> domainType, CosmosPatchOperations patchOperations, CosmosPatchItemRequestOptions options)

patches item

abstract CosmosContainerProperties replaceContainerProperties(String containerName, CosmosContainerProperties properties)

Replace container properties for the specified container

abstract org.springframework.data.domain.Page<T> runPaginationQuery(SqlQuerySpec querySpec, Pageable pageable, Class<?> domainType, Class<T> returnType)

Run the query.

abstract Iterable<T> runQuery(SqlQuerySpec querySpec, Class<?> domainType, Class<T> returnType)

Run the query.

abstract Iterable<T> runQuery(SqlQuerySpec querySpec, Sort sort, Class<?> domainType, Class<T> returnType)

Run the query.

abstract org.springframework.data.domain.Slice<T> runSliceQuery(SqlQuerySpec querySpec, Pageable pageable, Class<?> domainType, Class<T> returnType)

Run custom SQL query

abstract org.springframework.data.domain.Slice<T> sliceQuery(CosmosQuery query, Class<T> domainType, String containerName)

Slice query

abstract long sum(SqlQuerySpec querySpec, String containerName)

Sum

abstract void upsert(String containerName, T object)

Upserts an item into container with partition key

abstract void upsert(T object)

Upserts an item with partition key

abstract T upsertAndReturnEntity(String containerName, T object)

Upserts an item and return item properties

Method Details

<S,T>deleteEntities

public abstract void deleteEntities(CosmosEntityInformation information, Iterable entities)

Delete using a list of entities with bulk

Parameters:

information - must not be null
entities - must not be null

<S,T>insertAll

public abstract Iterable insertAll(CosmosEntityInformation information, Iterable entities)

Insert items using bulk operations.

Parameters:

information - must not be null
entities - must not be null

Returns:

the inserted item

<T,ID>findByIds

public abstract Iterable findByIds(Iterable ids, Class domainType, String containerName)

Find by ids

Parameters:

ids - iterable of ids
domainType - type class
containerName - the container name

Returns:

results in an Iterable

count

public abstract long count(CosmosQuery query, String containerName)

Count

Parameters:

query - the document query
containerName - the container name

Returns:

count result

count

public abstract long count(SqlQuerySpec querySpec, String containerName)

Count

Parameters:

querySpec - the document query spec
containerName - the container name

Returns:

count result

count

public abstract long count(String containerName)

Count

Parameters:

containerName - the container name

Returns:

count result

createContainerIfNotExists

public abstract CosmosContainerProperties createContainerIfNotExists(CosmosEntityInformation information)

Creates container if not exists

Parameters:

information - CosmosEntityInformation

Returns:

CosmosContainerProperties

delete

public abstract Iterable delete(CosmosQuery query, Class domainType, String containerName)

Delete items matching query. Uses bulk if possible.

Parameters:

query - the document query
domainType - type class
containerName - the container name

Returns:

deleted items in a Iterable

deleteAll

public abstract void deleteAll(String containerName, Class domainType)

Delete all items in a container. Uses bulk if possible.

Parameters:

containerName - the container name
domainType - the domainType

deleteById

public abstract void deleteById(String containerName, Object id, PartitionKey partitionKey)

Delete an item by id

Parameters:

containerName - the container name
id - the id
partitionKey - the partition key

deleteContainer

public abstract void deleteContainer(String containerName)

Delete container

Parameters:

containerName - the container name

deleteEntity

public abstract void deleteEntity(String containerName, T entity)

Delete using entity

Parameters:

containerName - the container name
entity - the entity object

exists

public abstract Boolean exists(CosmosQuery query, Class domainType, String containerName)

Exists

Parameters:

query - the document query
domainType - type class
containerName - the container name

Returns:

Boolean

find

public abstract Iterable find(CosmosQuery query, Class domainType, String containerName)

Find query

Parameters:

query - the document query
domainType - type class
containerName - the container name

Returns:

results in an Iterable

findAll

public abstract Iterable findAll(Class domainType)

Find the DocumentQuery, find all the items specified by domain type.

Parameters:

domainType - the domain type

Returns:

results in an Iterable

findAll

public abstract Page findAll(Pageable pageable, Class domainType, String containerName)

Find all items in a given container with partition key

Parameters:

pageable - Pageable object
domainType - the domainType
containerName - the container name

Returns:

results as Page

findAll

public abstract Iterable findAll(PartitionKey partitionKey, Class domainType)

Find the DocumentQuery, find all the items specified by domain type in the given container.

Parameters:

partitionKey - the partition key
domainType - the domain type

Returns:

results in an Iterable

findAll

public abstract Iterable findAll(String containerName, Class domainType)

Find the DocumentQuery, find all the items specified by domain type in the given container.

Parameters:

containerName - the container name
domainType - the domain type

Returns:

results in an Iterable

findById

public abstract T findById(Object id, Class domainType)

Finds item by id

Parameters:

id - must not be null
domainType - must not be null

Returns:

found item

findById

public abstract T findById(Object id, Class domainType, PartitionKey partitionKey)

Finds item by id

Parameters:

id - must not be null
domainType - must not be null
partitionKey - must not be null

Returns:

found item

findById

public abstract T findById(String containerName, Object id, Class domainType)

Finds item by id

Parameters:

containerName - must not be null
id - must not be null
domainType - must not be null

Returns:

found item

getContainerName

public abstract String getContainerName(Class domainType)

To get container name by domainType

Parameters:

domainType - class type

Returns:

String

getContainerProperties

public abstract CosmosContainerProperties getContainerProperties(String containerName)

Get properties for specified container

Parameters:

containerName - String

Returns:

CosmosContainerProperties

getConverter

public abstract MappingCosmosConverter getConverter()

To get converter

Returns:

MappingCosmosConverter

insert

public abstract T insert(String containerName, T objectToSave)

Inserts item

Parameters:

containerName - must not be null
objectToSave - must not be null

Returns:

the inserted item

insert

public abstract T insert(String containerName, T objectToSave, PartitionKey partitionKey)

Inserts item

Parameters:

containerName - must not be null
objectToSave - must not be null
partitionKey - must not be null

Returns:

the inserted item

insert

public abstract T insert(T objectToSave, PartitionKey partitionKey)

Inserts item

Parameters:

objectToSave - must not be null
partitionKey - must not be null

Returns:

the inserted item

paginationQuery

public abstract Page paginationQuery(CosmosQuery query, Class domainType, String containerName)

Pagination query

Parameters:

query - the document query
domainType - type class
containerName - the container name

Returns:

results as Page

patch

public abstract T patch(Object id, PartitionKey partitionKey, Class domainType, CosmosPatchOperations patchOperations)

patches item

Parameters:

id - must not be null
partitionKey - must not be null
domainType - must not be null
patchOperations - must not be null, max operations is 10

Returns:

the patched item

patch

public abstract T patch(Object id, PartitionKey partitionKey, Class domainType, CosmosPatchOperations patchOperations, CosmosPatchItemRequestOptions options)

patches item

Parameters:

id - must not be null
partitionKey - must not be null
domainType - must not be null
patchOperations - must not be null, max operations is 10
options - Optional CosmosPatchItemRequestOptions, e.g. options.setFilterPredicate("FROM products p WHERE p.used = false");

Returns:

the patched item

replaceContainerProperties

public abstract CosmosContainerProperties replaceContainerProperties(String containerName, CosmosContainerProperties properties)

Replace container properties for the specified container

Parameters:

containerName - String
properties - CosmosContainerProperties

Returns:

CosmosContainerProperties

runPaginationQuery

public abstract Page runPaginationQuery(SqlQuerySpec querySpec, Pageable pageable, Class domainType, Class returnType)

Run the query.

Parameters:

querySpec - the query spec
pageable - the pageable
domainType - the domain type
returnType - the return type

Returns:

the Page

runQuery

public abstract Iterable runQuery(SqlQuerySpec querySpec, Class domainType, Class returnType)

Run the query.

Parameters:

querySpec - the query spec
domainType - the domain type
returnType - the return type

Returns:

the Iterable

runQuery

public abstract Iterable runQuery(SqlQuerySpec querySpec, Sort sort, Class domainType, Class returnType)

Run the query.

Parameters:

querySpec - the query spec
sort - the sort order
domainType - the domain type
returnType - the return type

Returns:

the Iterable

runSliceQuery

public abstract Slice runSliceQuery(SqlQuerySpec querySpec, Pageable pageable, Class domainType, Class returnType)

Run custom SQL query

Parameters:

querySpec - the query spec
pageable - the pageable
domainType - the domain type
returnType - the return type

Returns:

the Page

sliceQuery

public abstract Slice sliceQuery(CosmosQuery query, Class domainType, String containerName)

Slice query

Parameters:

query - the document query
domainType - type class
containerName - the container name

Returns:

results as Slice

sum

public abstract long sum(SqlQuerySpec querySpec, String containerName)

Sum

Parameters:

querySpec - the document query spec
containerName - the container name

Returns:

sum result

upsert

public abstract void upsert(String containerName, T object)

Upserts an item into container with partition key

Parameters:

containerName - the container name
object - upsert object

upsert

public abstract void upsert(T object)

Upserts an item with partition key

Parameters:

object - upsert object

upsertAndReturnEntity

public abstract T upsertAndReturnEntity(String containerName, T object)

Upserts an item and return item properties

Parameters:

containerName - the container name
object - upsert object

Returns:

upsert object entity

Applies to