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 TypeMethodDescriptionlong
Total number of elements with given type available.long
count
(KeyValueQuery<?> query, Class<?> type) Total number of elements matching given query.void
Remove all elements of type.<T> T
Delete item of type with given id.<T> T
delete
(T objectToDelete) <T> T
execute
(KeyValueCallback<T> action) Execute operation against underlying store.boolean
exists
(KeyValueQuery<?> query, Class<?> type) Determine whether result of givenKeyValueQuery
contains 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> T
Add object with given id.<T> T
insert
(T objectToInsert) Add given object.<T> T
<T> T
update
(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. RespectsKeySpace
if 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. RespectsKeySpace
if 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. RespectsKeySpace
if 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.
RespectsKeySpace
if 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. RespectsKeySpace
if 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. RespectsKeySpace
if 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. RespectsKeySpace
if 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. RespectsKeySpace
if 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. RespectsKeySpace
if present and therefore counts all elements that can be assigned to requested type.- Parameters:
query
-type
-- Returns:
-
exists
Determine whether result of givenKeyValueQuery
contains at least one element.- Parameters:
query
-type
-- Returns:
- Since:
- 2.7
-
getMappingContext
MappingContext<?,?> getMappingContext()- Returns:
- mapping context in use.
-