Class SimpleCosmosRepository<T,ID extends Serializable>
java.lang.Object
com.azure.spring.data.cosmos.repository.support.SimpleCosmosRepository<T,ID>
- Type Parameters:
T- domain type.ID- id type.
- All Implemented Interfaces:
CosmosRepository<T,,ID> org.springframework.data.repository.CrudRepository<T,,ID> org.springframework.data.repository.PagingAndSortingRepository<T,,ID> org.springframework.data.repository.Repository<T,ID>
public class SimpleCosmosRepository<T,ID extends Serializable>
extends Object
implements CosmosRepository<T,ID>
Repository class for simple Cosmos operation
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleCosmosRepository(CosmosEntityInformation<T, ID> metadata, CosmosOperations dbOperations) Initialization -
Method Summary
Modifier and TypeMethodDescriptionlongcount()return count of documents in one container without partitionsvoiddelete one document per entityvoidDelete all the domains of a container.voidDelete list of entities without partitions.voiddeleteAllById(Iterable<? extends ID> ids) voiddeleteById(ID id) delete one document per id without configuring partition key valuevoiddeleteById(ID id, com.azure.cosmos.models.PartitionKey partitionKey) Deletes an entity by its id and partition key.booleanexistsById(ID primaryKey) check if an entity exists per id without partitionfindAll()find all entities from one container without configuring partition key valuefindAll(com.azure.cosmos.models.PartitionKey partitionKey) Returns list of items in a specific partitionorg.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable) FindQuerySpecGenerator Returns a Page of entities meeting the paging restriction provided in the Pageable object.findAll(org.springframework.data.domain.Sort sort) Returns all entities sorted by the given options.findAllById(Iterable<ID> ids) find entities based on id list from one container without partitionsfind one entity per id without partitionsRetrieves an entity by its id.<S extends T>
Ssave(ID id, com.azure.cosmos.models.PartitionKey partitionKey, Class<S> domainType, com.azure.cosmos.models.CosmosPatchOperations patchOperations) patch entity with CosmosPatchItemRequestOptions<S extends T>
Ssave(ID id, com.azure.cosmos.models.PartitionKey partitionKey, Class<S> domainType, com.azure.cosmos.models.CosmosPatchOperations patchOperations, com.azure.cosmos.models.CosmosPatchItemRequestOptions options) patch entity with CosmosPatchItemRequestOptions<S extends T>
Ssave(S entity) save entity without partitionBatch save entities.
-
Constructor Details
-
SimpleCosmosRepository
public SimpleCosmosRepository(CosmosEntityInformation<T, ID> metadata, CosmosOperations dbOperations) Initialization- Parameters:
metadata- for cosmos entity informationdbOperations- for cosmosDB operation
-
-
Method Details
-
save
save entity without partition- Specified by:
savein interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Type Parameters:
S- type of entity- Parameters:
entity- to be saved- Returns:
- entity
-
save
public <S extends T> S save(ID id, com.azure.cosmos.models.PartitionKey partitionKey, Class<S> domainType, com.azure.cosmos.models.CosmosPatchOperations patchOperations) patch entity with CosmosPatchItemRequestOptions- Specified by:
savein interfaceCosmosRepository<T,ID extends Serializable> - Type Parameters:
S- domainType of entity- Parameters:
id- of entity to be patchedpartitionKey- of entity to be patcheddomainType- must not be nullpatchOperations- for entity to be patched- Returns:
- the patched entity
-
save
public <S extends T> S save(ID id, com.azure.cosmos.models.PartitionKey partitionKey, Class<S> domainType, com.azure.cosmos.models.CosmosPatchOperations patchOperations, com.azure.cosmos.models.CosmosPatchItemRequestOptions options) patch entity with CosmosPatchItemRequestOptions- Specified by:
savein interfaceCosmosRepository<T,ID extends Serializable> - Type Parameters:
S- domainType of entity- Parameters:
id- of entity to be patchedpartitionKey- of entity to be patcheddomainType- must not be nullpatchOperations- for entity to be patchedoptions- options- Returns:
- the patched entity
-
saveAll
Batch save entities. Uses bulk if possible.- Specified by:
saveAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Type Parameters:
S- type of entities- Parameters:
entities- Batch entities- Returns:
- return the saved entities
-
findAll
find all entities from one container without configuring partition key value- Specified by:
findAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Returns:
- return Iterable of the found entities List
-
findAllById
find entities based on id list from one container without partitions- Specified by:
findAllByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
ids- id list used to find entities- Returns:
- return a List of all found entities
-
findById
find one entity per id without partitions- Specified by:
findByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
id- an id used to find entity- Returns:
- return the searching result
-
findById
Description copied from interface:CosmosRepositoryRetrieves an entity by its id.- Specified by:
findByIdin interfaceCosmosRepository<T,ID extends Serializable> - Parameters:
id- must not be null.partitionKey- partition key value of entity, must not be null.- Returns:
- the entity with the given id or Optional#empty() if none found
-
count
public long count()return count of documents in one container without partitions- Specified by:
countin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Returns:
- count of documents in one container without partitions
-
deleteById
delete one document per id without configuring partition key value- Specified by:
deleteByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
id- an id used to specify the deleted document
-
deleteById
Description copied from interface:CosmosRepositoryDeletes an entity by its id and partition key.- Specified by:
deleteByIdin interfaceCosmosRepository<T,ID extends Serializable> - Parameters:
id- must not be null.partitionKey- partition key value of the entity, must not be null.
-
delete
delete one document per entity- Specified by:
deletein interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
entity- the entity used to specify a document
-
deleteAllById
- Specified by:
deleteAllByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable>
-
deleteAll
public void deleteAll()Delete all the domains of a container. Uses bulk if possible.- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable>
-
deleteAll
Delete list of entities without partitions. Uses bulk if possible.- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
entities- list of entities to be deleted
-
existsById
check if an entity exists per id without partition- Specified by:
existsByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable> - Parameters:
primaryKey- an id to specify an entity- Returns:
- if the entity exists
-
findAll
Returns all entities sorted by the given options.- Specified by:
findAllin interfaceorg.springframework.data.repository.PagingAndSortingRepository<T,ID extends Serializable> - Parameters:
sort- the Sort option for queries.- Returns:
- all entities sorted by the given options
-
findAll
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable) FindQuerySpecGenerator Returns a Page of entities meeting the paging restriction provided in the Pageable object.- Specified by:
findAllin interfaceorg.springframework.data.repository.PagingAndSortingRepository<T,ID extends Serializable> - Parameters:
pageable- the Pageable object providing paging restriction- Returns:
- a page of entities
-
findAll
Description copied from interface:CosmosRepositoryReturns list of items in a specific partition- Specified by:
findAllin interfaceCosmosRepository<T,ID extends Serializable> - Parameters:
partitionKey- partition key value- Returns:
- Iterable of items with partition key value
-