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
Constructors Constructor Description SimpleCosmosRepository(CosmosEntityInformation<T,ID> metadata, CosmosOperations dbOperations)Initialization
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcount()return count of documents in one container without partitionsvoiddelete(T entity)delete one document per entityvoiddeleteAll()delete all the domains of a containervoiddeleteAll(Iterable<? extends T> entities)delete list of entities without partitionsvoiddeleteAllById(Iterable<? extends ID> ids)voiddeleteById(ID id)delete one document per id without configuring partition key valuevoiddeleteById(ID id, PartitionKey partitionKey)Deletes an entity by its id and partition key.booleanexistsById(ID primaryKey)check if an entity exists per id without partitionIterable<T>findAll()find all entities from one container without configuring partition key valueIterable<T>findAll(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.Iterable<T>findAll(org.springframework.data.domain.Sort sort)Returns all entities sorted by the given options.Iterable<T>findAllById(Iterable<ID> ids)find entities based on id list from one container without partitionsOptional<T>findById(ID id)find one entity per id without partitionsOptional<T>findById(ID id, PartitionKey partitionKey)Retrieves an entity by its id.<S extends T>
Ssave(S entity)save entity without partition<S extends T>
Iterable<S>saveAll(Iterable<S> entities)batch save entities
-
-
-
Constructor Detail
-
SimpleCosmosRepository
public SimpleCosmosRepository(CosmosEntityInformation<T,ID> metadata, CosmosOperations dbOperations)
Initialization- Parameters:
metadata- for cosmos entity informationdbOperations- for cosmosDB operation
-
-
Method Detail
-
save
public <S extends T> S save(S entity)
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
-
saveAll
public <S extends T> Iterable<S> saveAll(Iterable<S> entities)
batch save entities- 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
public Iterable<T> 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
public Iterable<T> findAllById(Iterable<ID> ids)
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
public Optional<T> findById(ID id)
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
public Optional<T> findById(ID id, PartitionKey partitionKey)
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
public void deleteById(ID id)
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
public void deleteById(ID id, PartitionKey partitionKey)
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
public void delete(T entity)
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
public void deleteAllById(Iterable<? extends ID> ids)
- Specified by:
deleteAllByIdin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable>
-
deleteAll
public void deleteAll()
delete all the domains of a container- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable>
-
deleteAll
public void deleteAll(Iterable<? extends T> entities)
delete list of entities without partitions- Specified by:
deleteAllin interfaceorg.springframework.data.repository.CrudRepository<T,ID extends Serializable>- Parameters:
entities- list of entities to be deleted
-
existsById
public boolean existsById(ID primaryKey)
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
public Iterable<T> findAll(@NonNull org.springframework.data.domain.Sort sort)
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
public Iterable<T> findAll(PartitionKey partitionKey)
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
-
-