CosmosTemplate Class
- java.
lang. Object - com.
azure. spring. data. cosmos. core. CosmosTemplate
- com.
Implements
public class CosmosTemplate
implements CosmosOperations, org.springframework.context.ApplicationContextAware
Template class for cosmos db
Constructor Summary
Method Summary
Methods inherited from java.lang.Object
Constructor Details
CosmosTemplate
public CosmosTemplate(CosmosAsyncClient client, String databaseName, CosmosConfig cosmosConfig, MappingCosmosConverter mappingCosmosConverter)
Initialization
Parameters:
CosmosTemplate
public CosmosTemplate(CosmosAsyncClient client, String databaseName, CosmosConfig cosmosConfig, MappingCosmosConverter mappingCosmosConverter, IsNewAwareAuditingHandler cosmosAuditingHandler)
Initialization
Parameters:
CosmosTemplate
public CosmosTemplate(CosmosFactory cosmosFactory, CosmosConfig cosmosConfig, MappingCosmosConverter mappingCosmosConverter)
Initialization
Parameters:
CosmosTemplate
public CosmosTemplate(CosmosFactory cosmosFactory, CosmosConfig cosmosConfig, MappingCosmosConverter mappingCosmosConverter, IsNewAwareAuditingHandler cosmosAuditingHandler)
Initialization
Parameters:
Method Details
<S,T>deleteEntities
public void deleteEntities(CosmosEntityInformation entities)
Deletes the entities using bulk
Parameters:
<S,T>insertAll
public Iterable insertAll(CosmosEntityInformation entities)
Insert all items with bulk.
Parameters:
Returns:
<T,ID>findByIds
public Iterable
Find by ids
Parameters:
count
public long
Count
Parameters:
count
public long
Count
Parameters:
delete
public Iterable
Delete the DocumentQuery, need to query the domains at first, then delete the item from the result. The cosmos db Sql API do _NOT_ support DELETE query, we cannot add one DeleteQueryGenerator. Uses bulk if possible.
Parameters:
Returns:
deleteEntity
public void
Deletes the entity
Parameters:
exists
public Boolean
Checks if document query items exist
Parameters:
Returns:
find
public Iterable
Finds the document query items
Parameters:
Returns:
findAll
public Iterable
Find the DocumentQuery, find all the items specified by domain type in the given container.
Parameters:
findAll
public Iterable
Find the DocumentQuery, find all the items specified by domain type.
Parameters:
Returns:
findAll
public Iterable
Find the DocumentQuery, find all the items specified by domain type in the given container.
Parameters:
Returns:
findAll
public Page
Find all items in a given container with partition key
Parameters:
findById
public T
Finds item by id
Parameters:
Returns:
findById
public T
Finds item by id
Parameters:
findById
public T
Finds item by id
Parameters:
Returns:
insert
public T
Inserts item
Parameters:
Returns:
insert
public T
Inserts item into the given container
Parameters:
Returns:
insert
public T
Inserts item into the given container
Parameters:
Returns:
paginationQuery
public Page
Pagination query
Parameters:
patch
public T
Patches item applies partial update (patch) to an item
Parameters:
Returns:
patch
public T
applies partial update (patch) to an item with CosmosPatchItemRequestOptions
Parameters:
Returns:
runPaginationQuery
public Page
Run the query.
Parameters:
runQuery
public Iterable
Run the query.
Parameters:
runQuery
public Iterable
Run the query.
Parameters:
runSliceQuery
public Slice
Run custom SQL query
Parameters:
sliceQuery
public Slice
Slice query
Parameters:
upsert
public void
Upserts an item with partition key
Parameters:
upsert
public void
Upserts an item into container with partition key
Parameters:
upsertAndReturnEntity
public T
Upserts an item and return item properties
Parameters:
Returns:
count
public long count(String containerName)
Count
Parameters:
createContainerIfNotExists
public CosmosContainerProperties createContainerIfNotExists(CosmosEntityInformation information)
Creates container if not exists
Parameters:
deleteAll
public void deleteAll(String containerName, Class domainType)
Delete the DocumentQuery, delete all the items in the given container.
Parameters:
deleteById
public void deleteById(String containerName, Object id, PartitionKey partitionKey)
Deletes the item by id and partition key.
Parameters:
deleteContainer
public void deleteContainer(String containerName)
Delete container
Parameters:
getContainerName
public String getContainerName(Class domainType)
To get container name by domainType
Parameters:
getContainerNameOverride
public String getContainerNameOverride(String containerName)
Check if an overridden version of containerName is present, and if so, return it
Parameters:
Returns:
getContainerProperties
public CosmosContainerProperties getContainerProperties(String containerName)
Get properties for specified container
Parameters:
getConverter
public MappingCosmosConverter getConverter()
To get converter
replaceContainerProperties
public CosmosContainerProperties replaceContainerProperties(String containerName, CosmosContainerProperties properties)
Replace container properties for the specified container
Parameters:
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
Sets the application context
Parameters:
Throws:
Applies to
Azure SDK for Java