Module spring.data.keyvalue
Interface KeyValueOperations
- All Superinterfaces:
DisposableBean
- All Known Implementing Classes:
KeyValueTemplate
Interface that specifies a basic set of key/value operations. Implemented by
KeyValueTemplate.- Author:
- Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptionlongTotal number of elements with given type available.longcount(KeyValueQuery<?> query, Class<?> type) Total number of elements matching given query.voidRemove all elements of type.<T> TDelete item of type with given id.<T> Tdelete(T objectToDelete) <T> Texecute(KeyValueCallback<T> action) Execute operation against underlying store.booleanexists(KeyValueQuery<?> query, Class<?> type) Determine whether result of givenKeyValueQuerycontains at least one element.<T> Iterable<T>find(KeyValueQuery<?> query, Class<T> type) Get all elements matching the given query.<T> Iterable<T>Get all elements of given type.<T> Iterable<T>Get all elements ordered by sort.<T> Optional<T>Get element of given type with given id.<T> Iterable<T>findInRange(long offset, int rows, Class<T> type) Get all elements in given range.<T> Iterable<T>findInRange(long offset, int rows, Sort sort, Class<T> type) Get all elements in given range ordered by sort.MappingContext<?,?> <T> TAdd object with given id.<T> Tinsert(T objectToInsert) Add given object.<T> T<T> Tupdate(T objectToUpdate) Methods inherited from interface org.springframework.beans.factory.DisposableBean
destroy
-
Method Details
-
insert
<T> T insert(T objectToInsert) Add given object. Object needs to have id property to which a generated value will be assigned.- Parameters:
objectToInsert-- Returns:
- the inserted object.
-
insert
Add object with given id.- Parameters:
id- must not be null.objectToInsert- must not be null.- Returns:
- the inserted object.
-
findAll
Get all elements of given type. RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type.- Parameters:
type- must not be null.- Returns:
- empty iterable if no elements found.
-
findAll
Get all elements ordered by sort. RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type.- Parameters:
sort- must not be null.type- must not be null.- Returns:
-
findById
Get element of given type with given id. RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type.- Parameters:
id- must not be null.type- must not be null.- Returns:
Optional.empty()if not found.
-
execute
Execute operation against underlying store.- Parameters:
action- must not be null.- Returns:
-
find
Get all elements matching the given query.
RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type..- Parameters:
query- must not be null.type- must not be null.- Returns:
- empty iterable if no match found.
-
findInRange
Get all elements in given range. RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type.- Parameters:
offset-rows-type- must not be null.- Returns:
-
findInRange
Get all elements in given range ordered by sort. RespectsKeySpaceif present and therefore returns all elements that can be assigned to requested type.- Parameters:
offset-rows-sort-type-- Returns:
-
update
<T> T update(T objectToUpdate) - Parameters:
objectToUpdate- must not be null.- Returns:
- the updated object.
-
update
- Parameters:
id- must not be null.objectToUpdate- must not be null.- Returns:
- the updated object.
-
delete
Remove all elements of type. RespectsKeySpaceif present and therefore removes all elements that can be assigned to requested type.- Parameters:
type- must not be null.
-
delete
- Parameters:
objectToDelete- must not be null.- Returns:
-
delete
Delete item of type with given id.- Parameters:
id- must not be null.type- must not be null.- Returns:
- the deleted item or null if no match found.
-
count
Total number of elements with given type available. RespectsKeySpaceif present and therefore counts all elements that can be assigned to requested type.- Parameters:
type- must not be null.- Returns:
-
count
Total number of elements matching given query. RespectsKeySpaceif present and therefore counts all elements that can be assigned to requested type.- Parameters:
query-type-- Returns:
-
exists
Determine whether result of givenKeyValueQuerycontains at least one element.- Parameters:
query-type-- Returns:
- Since:
- 2.7
-
getMappingContext
MappingContext<?,?> getMappingContext()- Returns:
- mapping context in use.
-
getKeyValueAdapter
KeyValueAdapter getKeyValueAdapter()- Returns:
KeyValueAdapterin use.- Since:
- 3.2.4
-