public class KeyValueTemplate extends Object implements KeyValueOperations, ApplicationEventPublisherAware
KeyValueOperations
.Constructor and Description |
---|
KeyValueTemplate(KeyValueAdapter adapter)
|
KeyValueTemplate(KeyValueAdapter adapter,
MappingContext<? extends KeyValuePersistentEntity<?>,? extends KeyValuePersistentProperty> mappingContext)
|
Modifier and Type | Method and Description |
---|---|
long |
count(Class<?> type)
Total number of elements with given type available.
|
long |
count(KeyValueQuery<?> query,
Class<?> type)
Total number of elements matching given query.
|
void |
delete(Class<?> type)
Remove all elements of type.
|
<T> T |
delete(Serializable id,
Class<T> type)
Delete item of type with given id.
|
<T> T |
delete(T objectToDelete) |
void |
destroy() |
<T> T |
execute(KeyValueCallback<T> action)
Execute operation against underlying store.
|
<T> Iterable<T> |
find(KeyValueQuery<?> query,
Class<T> type)
Get all elements matching the given query.
|
<T> Iterable<T> |
findAll(Class<T> type)
Get all elements of given type.
|
<T> Iterable<T> |
findAll(Sort sort,
Class<T> type)
Get all elements ordered by sort.
|
<T> T |
findById(Serializable id,
Class<T> type)
Get element of given type with given id.
|
<T> Iterable<T> |
findInRange(int offset,
int rows,
Class<T> type)
Get all elements in given range.
|
<T> Iterable<T> |
findInRange(int offset,
int rows,
Sort sort,
Class<T> type)
Get all elements in given range ordered by sort.
|
MappingContext<?,?> |
getMappingContext() |
void |
insert(Serializable id,
Object objectToInsert)
Add object with given id.
|
<T> T |
insert(T objectToInsert)
Add given object.
|
void |
setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) |
void |
setEventTypesToPublish(Set<Class<? extends KeyValueEvent>> eventTypesToPublish)
Define the event types to publish via
ApplicationEventPublisher . |
void |
setExceptionTranslator(PersistenceExceptionTranslator exceptionTranslator)
Set the
PersistenceExceptionTranslator used for converting RuntimeException . |
void |
update(Object objectToUpdate) |
void |
update(Serializable id,
Object objectToUpdate) |
public KeyValueTemplate(KeyValueAdapter adapter)
adapter
- must not be null.public KeyValueTemplate(KeyValueAdapter adapter, MappingContext<? extends KeyValuePersistentEntity<?>,? extends KeyValuePersistentProperty> mappingContext)
adapter
- must not be null.mappingContext
- must not be null.public void setExceptionTranslator(PersistenceExceptionTranslator exceptionTranslator)
PersistenceExceptionTranslator
used for converting RuntimeException
.exceptionTranslator
- must not be null.public void setEventTypesToPublish(Set<Class<? extends KeyValueEvent>> eventTypesToPublish)
ApplicationEventPublisher
.eventTypesToPublish
- use null or Collections.emptySet()
to stop publishing.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
public <T> T insert(T objectToInsert)
KeyValueOperations
insert
in interface KeyValueOperations
public void insert(Serializable id, Object objectToInsert)
KeyValueOperations
insert
in interface KeyValueOperations
id
- must not be null.objectToInsert
- must not be null.public void update(Object objectToUpdate)
update
in interface KeyValueOperations
objectToUpdate
- must not be null.public void update(Serializable id, Object objectToUpdate)
update
in interface KeyValueOperations
id
- must not be null.objectToUpdate
- must not be null.public <T> Iterable<T> findAll(Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all elements that can be
assigned to requested type.findAll
in interface KeyValueOperations
type
- must not be null.public <T> T findById(Serializable id, Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all elements
that can be assigned to requested type.findById
in interface KeyValueOperations
id
- must not be null.type
- must not be null.public void delete(Class<?> type)
KeyValueOperations
KeySpace
if present and therefore removes all elements that can be
assigned to requested type.delete
in interface KeyValueOperations
type
- must not be null.public <T> T delete(T objectToDelete)
delete
in interface KeyValueOperations
objectToDelete
- must not be null.public <T> T delete(Serializable id, Class<T> type)
KeyValueOperations
delete
in interface KeyValueOperations
id
- must not be null.type
- must not be null.public long count(Class<?> type)
KeyValueOperations
KeySpace
if present and therefore counts all
elements that can be assigned to requested type.count
in interface KeyValueOperations
type
- must not be null.public <T> T execute(KeyValueCallback<T> action)
KeyValueOperations
execute
in interface KeyValueOperations
action
- must not be null.public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all elements that can be assigned to requested type..find
in interface KeyValueOperations
query
- must not be null.type
- must not be null.public <T> Iterable<T> findAll(Sort sort, Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all elements that can
be assigned to requested type.findAll
in interface KeyValueOperations
sort
- must not be null.type
- must not be null.public <T> Iterable<T> findInRange(int offset, int rows, Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all elements that can
be assigned to requested type.findInRange
in interface KeyValueOperations
type
- must not be null.public <T> Iterable<T> findInRange(int offset, int rows, Sort sort, Class<T> type)
KeyValueOperations
KeySpace
if present and therefore returns all
elements that can be assigned to requested type.findInRange
in interface KeyValueOperations
public long count(KeyValueQuery<?> query, Class<?> type)
KeyValueOperations
KeySpace
if present and therefore counts all
elements that can be assigned to requested type.count
in interface KeyValueOperations
public MappingContext<?,?> getMappingContext()
getMappingContext
in interface KeyValueOperations
public void destroy() throws Exception
destroy
in interface DisposableBean
Exception
Copyright © 2011-2016–2016 Pivotal Software, Inc.. All rights reserved.