I
InsightNexus

CosmosTemplate (Azure SDK for Java Reference Documentation)

Author

James Stevens

Published Feb 16, 2026

All Methods Instance Methods Concrete Methods Modifier and TypeMethod and Description<T> longcount(CosmosQuery query, String containerName)

Count

longcount(String containerName)

Count

CosmosContainerPropertiescreateContainerIfNotExists(CosmosEntityInformation<?,?> information)

Creates container if not exists

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

Delete the DocumentQuery, need to query the domains at first, then delete the item from the result.

voiddeleteAll(String containerName, Class<?> domainType)

Delete the DocumentQuery, delete all the items in the given container.

voiddeleteById(String containerName, Object id, PartitionKey partitionKey)

Deletes the item by id and partition key.

voiddeleteContainer(String containerName)

Delete container

<T> voiddeleteEntity(String containerName, T entity)

Deletes the entity

<T> Booleanexists(CosmosQuery query, Class<T> domainType, String containerName)

Checks if document query items exist

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

Finds the document query items

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

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

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

Find all items in a given container with partition key

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

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

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

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

<T> TfindById(Object id, Class<T> domainType)

Finds item by id

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

Finds item by id

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

Finds item by id

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

Find by ids

StringgetContainerName(Class<?> domainType)

To get container name by domainType

MappingCosmosConvertergetConverter()

To get converter

<T> Tinsert(String containerName, T objectToSave)

Inserts item into the given container

<T> Tinsert(String containerName, T objectToSave, PartitionKey partitionKey)

Inserts item into the given container

<T> Tinsert(T objectToSave, PartitionKey partitionKey)

Inserts item

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

Pagination query

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

Run the query.

voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)

Sets the application context

<T> voidupsert(String containerName, T object)

Upserts an item into container with partition key

<T> voidupsert(T object)

Upserts an item with partition key

<T> TupsertAndReturnEntity(String containerName, T object)

Upserts an item and return item properties