public interface DatastoreOperations
Modifier and Type | Method and Description |
---|---|
long |
count(Class<?> entityClass)
Count all occurrences of entities of the given domain type.
|
Key |
createKey(Class aClass,
Object id)
Create a
Key from entity class and id value. |
Key |
createKey(String kind,
Object id)
Create a
Key from kind name and id. |
<T> void |
delete(T entity)
Delete an entity from Cloud Datastore.
|
long |
deleteAll(Class<?> entityClass)
Delete all entities of a given domain type.
|
<T> void |
deleteAll(Iterable<T> entities)
Deletes multiple entities from Cloud Datastore.
|
<T> void |
deleteAllById(Iterable<?> ids,
Class<T> entityClass)
Delete multiple IDs from Cloud Datastore.
|
<T> void |
deleteById(Object id,
Class<T> entityClass)
Delete an entity from Cloud Datastore.
|
<T> boolean |
existsById(Object id,
Class<T> entityClass)
Check if the given ID belongs to an entity in Cloud Datastore.
|
<T> Iterable<T> |
findAll(Class<T> entityClass)
Get all the entities of the given domain type.
|
<T> Collection<T> |
findAll(Class<T> entityClass,
DatastoreQueryOptions queryOptions)
Get all the entities of the given domain type applying limit, offset and sort.
|
<T> Iterable<T> |
findAllById(Iterable<?> ids,
Class<T> entityClass)
Find all the entities of the given IDs.
|
<T> T |
findById(Object id,
Class<T> entityClass)
Get an entity based on a id.
|
<T> Map<String,T> |
findByIdAsMap(Key key,
Class<T> valueType)
Get a Datastore entity based on a id and convert it to a map.
|
DatastoreEntityConverter |
getDatastoreEntityConverter()
Get the
DatastoreEntityConverter used by this template. |
Key |
getKey(Object entity)
Create a
Key from id property of an entity object. |
<T> Iterable<Key> |
keyQueryByExample(org.springframework.data.domain.Example<T> example,
DatastoreQueryOptions queryOptions)
Run key query by example.
|
<A> A |
performTransaction(Function<DatastoreOperations,A> operations)
Performs multiple read and write operations in a single transaction.
|
<T> Iterable<T> |
query(Query<? extends BaseEntity> query,
Class<T> entityClass)
Finds objects by using a Cloud Datastore query.
|
<A,T> Iterable<T> |
query(Query<A> query,
Function<A,T> entityFunc)
Runs given query and applies given function to each entity in the result.
|
<T> Iterable<T> |
queryByExample(org.springframework.data.domain.Example<T> example,
DatastoreQueryOptions queryOptions)
Run query by example.
|
<T> org.springframework.data.domain.Slice<T> |
queryEntitiesSlice(StructuredQuery query,
Class<T> entityClass,
org.springframework.data.domain.Pageable pageable)
Finds entities by using a Cloud Datastore query.
|
<A,T> DatastoreResultsIterable<T> |
queryIterable(Query<A> query,
Function<A,T> entityFunc)
Runs given query and applies given function to each entity in the result.
|
Iterable<Key> |
queryKeys(Query<Key> query)
Finds Cloud Datastore Keys by using a Cloud Datastore query.
|
<T> DatastoreResultsIterable<?> |
queryKeysOrEntities(Query query,
Class<T> entityClass)
Finds objects by using a Cloud Datastore query.
|
<T> org.springframework.data.domain.Slice<Key> |
queryKeysSlice(KeyQuery query,
Class<T> entityClass,
org.springframework.data.domain.Pageable pageable)
Finds keys by using a Cloud Datastore query.
|
<T> T |
save(T instance,
Key... ancestors)
Saves an instance of an object to Cloud Datastore.
|
<T> Iterable<T> |
saveAll(Iterable<T> entities,
Key... ancestors)
Saves multiple instances of objects to Cloud Datastore.
|
<V> void |
writeMap(Key key,
Map<String,V> map)
Save a map as a Datastore entity, using map keys as field names.
|
<T> T findById(Object id, Class<T> entityClass)
T
- the class type of the entity.id
- the id of the entity. If this is actually a
Key
then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass. param.entityClass
- the type of the entity to get.<T> T save(T instance, Key... ancestors)
T
- the type of the object to saveinstance
- the instance to save.ancestors
- ancestors that should be added to the entry<T> Iterable<T> saveAll(Iterable<T> entities, Key... ancestors)
T
- the type of entities to saveentities
- the objects to save.ancestors
- ancestors that should be added to each entry<T> void deleteById(Object id, Class<T> entityClass)
T
- ths entity typeid
- the ID of the entity to delete. If this is actually a
Key
then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.entityClass
- the type of the<T> void deleteAllById(Iterable<?> ids, Class<T> entityClass)
T
- ths entity typeids
- the IDs to delete. If any of these is actually a
Key
then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.entityClass
- the type of the<T> void delete(T entity)
T
- the entity typeentity
- the entity to delete.<T> void deleteAll(Iterable<T> entities)
T
- the entity type.entities
- the entities to delete.long deleteAll(Class<?> entityClass)
entityClass
- the domain type to delete from Cloud Datastore.long count(Class<?> entityClass)
entityClass
- the domain type to count.<T> Iterable<T> findAllById(Iterable<?> ids, Class<T> entityClass)
Key
then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.T
- the type parameter of the domain type.ids
- the IDs to search.entityClass
- the domain type of the objects.<T> Iterable<T> query(Query<? extends BaseEntity> query, Class<T> entityClass)
T
- the type of object to retrieve.query
- the query to execute.entityClass
- the type of object to retrieve.<A,T> Iterable<T> query(Query<A> query, Function<A,T> entityFunc)
A
- the row type of the query. This type can be either Key
or a
Cloud Datastore entity.T
- the type to map each entity or key to.query
- the query to run.entityFunc
- the function to apply to each found entity or key.Iterable<Key> queryKeys(Query<Key> query)
query
- the query to execute that retrieves only Keys.<T> Iterable<T> findAll(Class<T> entityClass)
T
- the type param of the domain type.entityClass
- the domain type to get.<T> Collection<T> findAll(Class<T> entityClass, DatastoreQueryOptions queryOptions)
T
- the type param of the domain type.entityClass
- the domain type to get.queryOptions
- query options<T> boolean existsById(Object id, Class<T> entityClass)
Key
then it will be used. Otherwise it will be
attempted to be converted to an integer or string value and it will be assumed to
be a root key value with the Kind determined by the entityClass.T
- the type param of the domain type.id
- the ID to search for.entityClass
- the domain type of the entities to search for.<A> A performTransaction(Function<DatastoreOperations,A> operations)
A
- the final return type of the operations.operations
- the function that uses DatastoreOperations
to perform operations in a transaction.<T> Map<String,T> findByIdAsMap(Key key, Class<T> valueType)
T
- the value type of the mapkey
- the key of the entityvalueType
- type values should be converted tonull
otherwise<V> void writeMap(Key key, Map<String,V> map)
V
- the value type of the map to writekey
- the key for the entitymap
- a mapKey createKey(String kind, Object id)
Key
from kind name and id.kind
- the Cloud Datastore kind nameid
- object to be used as id; if it is a Long, the value is used, otherwise it isconverted to StringKey createKey(Class aClass, Object id)
Key
from entity class and id value.aClass
- the Cloud Datastore entity classid
- object to be used as id; if it is a Long, the value is used, otherwise it is converted to StringKey getKey(Object entity)
Key
from id property of an entity object.entity
- the Cloud Datastore entity object<T> Iterable<T> queryByExample(org.springframework.data.domain.Example<T> example, DatastoreQueryOptions queryOptions)
T
- the type of probe and resulted entitiesexample
- the examplequeryOptions
- the query options<T> Iterable<Key> keyQueryByExample(org.springframework.data.domain.Example<T> example, DatastoreQueryOptions queryOptions)
T
- the type of probeexample
- the examplequeryOptions
- the query optionsDatastoreEntityConverter getDatastoreEntityConverter()
DatastoreEntityConverter
used by this template.<T> org.springframework.data.domain.Slice<Key> queryKeysSlice(KeyQuery query, Class<T> entityClass, org.springframework.data.domain.Pageable pageable)
T
- the type of object to retrieve.query
- the query to execute.entityClass
- the type of object to retrieve.pageable
- that indicates page number and page size<T> org.springframework.data.domain.Slice<T> queryEntitiesSlice(StructuredQuery query, Class<T> entityClass, org.springframework.data.domain.Pageable pageable)
T
- the type of object to retrieve.query
- the query to execute.entityClass
- the type of object to retrieve.pageable
- that indicates page number and page size<T> DatastoreResultsIterable<?> queryKeysOrEntities(Query query, Class<T> entityClass)
T
- the type of object to retrieve.query
- the query to execute.entityClass
- the type of object to retrieve.<A,T> DatastoreResultsIterable<T> queryIterable(Query<A> query, Function<A,T> entityFunc)
A
- the row type of the query. This type can be either Key
or a
Cloud Datastore entity.T
- the type to map each entity or key to.query
- the query to run.entityFunc
- the function to apply to each found entity or key.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.