Class SimpleCosmosRepository<T,ID extends Serializable>
java.lang.Object
com.azure.spring.data.cosmos.repository.support.SimpleCosmosRepository<T,ID>
- 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
ConstructorDescriptionSimpleCosmosRepository
(CosmosEntityInformation<T, ID> metadata, CosmosOperations dbOperations) Initialization -
Method Summary
Modifier and TypeMethodDescriptionlong
count()
return count of documents in one container without partitionsvoid
delete one document per entityvoid
delete all the domains of a containervoid
delete list of entities without partitionsvoid
deleteAllById
(Iterable<? extends ID> ids) void
deleteById
(ID id) delete one document per id without configuring partition key valuevoid
deleteById
(ID id, PartitionKey partitionKey) Deletes an entity by its id and partition key.boolean
existsById
(ID primaryKey) check if an entity exists per id without partitionfindAll()
find all entities from one container without configuring partition key valuefindAll
(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 partitionsfindById
(ID id, PartitionKey partitionKey) Retrieves an entity by its id.<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:
save
in interfaceorg.springframework.data.repository.CrudRepository<T,
ID extends Serializable> - Type Parameters:
S
- type of entity- Parameters:
entity
- to be saved- Returns:
- entity
-
saveAll
batch save entities- Specified by:
saveAll
in 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:
findAll
in 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:
findAllById
in 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:
findById
in 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:CosmosRepository
Retrieves an entity by its id.- Specified by:
findById
in 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:
count
in 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:
deleteById
in interfaceorg.springframework.data.repository.CrudRepository<T,
ID extends Serializable> - Parameters:
id
- an id used to specify the deleted document
-
deleteById
Description copied from interface:CosmosRepository
Deletes an entity by its id and partition key.- Specified by:
deleteById
in 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:
delete
in interfaceorg.springframework.data.repository.CrudRepository<T,
ID extends Serializable> - Parameters:
entity
- the entity used to specify a document
-
deleteAllById
- Specified by:
deleteAllById
in interfaceorg.springframework.data.repository.CrudRepository<T,
ID extends Serializable>
-
deleteAll
public void deleteAll()delete all the domains of a container- Specified by:
deleteAll
in interfaceorg.springframework.data.repository.CrudRepository<T,
ID extends Serializable>
-
deleteAll
delete list of entities without partitions- Specified by:
deleteAll
in 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:
existsById
in 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:
findAll
in 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:
findAll
in 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:CosmosRepository
Returns list of items in a specific partition- Specified by:
findAll
in interfaceCosmosRepository<T,
ID extends Serializable> - Parameters:
partitionKey
- partition key value- Returns:
- Iterable of items with partition key value
-