public interface Loader extends SimpleQuery<Object>
The top element in the command chain for retrieving entities from the datastore.
At this point you can enable load groups with group()
, start all-kinds
queries by calling query-related methods (see SimpleQuery), load entities by key or ref,
or narrow your interest to a specific kind by calling type()
.
All command objects are immutable.
Modifier and Type | Method and Description |
---|---|
<E> Map<Key<E>,E> |
entities(E... entities)
A convenient substitute for entities(Iterable)
|
<E> Map<Key<E>,E> |
entities(Iterable<E> entities)
Load multiple entities from the datastore in a batch.
|
<E> LoadResult<E> |
entity(E entity)
Load a single entity which has the same id/parent as the specified entity.
|
<T> T |
fromEntity(com.google.appengine.api.datastore.Entity entity)
Convert a native datastore Entity into a typed POJO.
|
Set<Class<?>> |
getLoadGroups() |
Objectify |
getObjectify() |
Loader |
group(Class<?>... groups)
Enables one or more fetch groups.
|
<E> LoadResult<E> |
key(Key<E> key)
Load a single entity by key.
|
<E> Map<Key<E>,E> |
keys(Iterable<Key<E>> keys)
Load multiple entities by key from the datastore in a batch.
|
<E> Map<Key<E>,E> |
keys(Key<? extends E>... keys)
A convenient substitute for keys(Iterable)
|
<E> E |
now(Key<E> key)
Get the entity for a key immediately.
|
<E> LoadResult<E> |
ref(Ref<E> ref)
Load a single entity ref.
|
<E> Map<Key<E>,E> |
refs(Iterable<Ref<E>> refs)
Load multiple refs in a batch operation.
|
<E> Map<Key<E>,E> |
refs(Ref<? extends E>... refs)
A convenient substitute for refs(Iterable)
|
<E> LoadType<E> |
type(Class<E> type)
Restricts the find operation to entities of a particular type.
|
<E> LoadResult<E> |
value(Object key)
Load a single entity given any of a variety of acceptable key-like structures.
|
<E> Map<Key<E>,E> |
values(Iterable<?> keysOrEntities)
Fetch multiple entities from the datastore in a batch.
|
<E> Map<Key<E>,E> |
values(Object... keysOrEntities)
A convenient substitute for values(Iterable)
|
ancestor, chunk, chunkAll, count, distinct, endAt, filterKey, filterKey, hybrid, keys, limit, offset, reverse, startAt, toString
first, iterable, list
Loader group(Class<?>... groups)
Enables one or more fetch groups. This will cause any entity fields (or Ref fields) which
are annotated with @Load(XYZGroup.class) to be fetched along with your entities. The class
definition can be any arbitrary class, but inheritance is respected - if you have a
class Foo extends Bar
, then group(Foo.class)
will cause loading of all @Load(Bar.class)
properties.
Calling this method multiple times is the same as passing all the groups into one call.
groups
- are one or more load groups to enable. They can be any arbitrary class.<E> LoadType<E> type(Class<E> type)
Restricts the find operation to entities of a particular type. The type may be the base of a polymorphic class hierarchy. This is optional.
type
- is the type of entity (or entities) to retrieve, possibly a base class for a polymorphic hierarchy<E> LoadResult<E> ref(Ref<E> ref)
Load a single entity ref. This starts an asynchronous fetch operation.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
can be thrown from Result
operations.
ref
- holds the key to fetch and will receive the asynchronous result.<E> Map<Key<E>,E> refs(Iterable<Ref<E>> refs)
Load multiple refs in a batch operation. This starts an asynchronous fetch.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
can be thrown from the map operations.
refs
- provide the keys to fetch and will receive the asynchronous result.<E> LoadResult<E> key(Key<E> key)
Load a single entity by key. This starts an asynchronous fetch.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
can be thrown from Result
operations.
key
- defines the entity to fetch<E> Map<Key<E>,E> keys(Iterable<Key<E>> keys)
Load multiple entities by key from the datastore in a batch. This starts an asynchronous fetch.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
will be thrown when the Map is accessed.
keys
- are the keys to fetch<E> LoadResult<E> entity(E entity)
Load a single entity which has the same id/parent as the specified entity. This starts an asynchronous fetch.
This is a shortcut for key(Key.create(entity))
.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
may be thrown from Result
operations.
entity
- defines the entity to fetch; it must be of a registered entity type and have valid id/parent fields.<E> Map<Key<E>,E> entities(Iterable<E> entities)
Load multiple entities from the datastore in a batch. This starts an asynchronous fetch.
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
may be thrown when the Map is accessed.
entities
- must be a list of objects which belong to registered entity types, and must have id & parent fields
properly set.<E> LoadResult<E> value(Object key)
Load a single entity given any of a variety of acceptable key-like structures. This starts an asynchronous fetch.
The parameter can be any key-like structure, including:
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
may be thrown from Result
operations.
key
- defines the entity to fetch; can be anything that represents a key structure<E> Map<Key<E>,E> values(Iterable<?> keysOrEntities)
Fetch multiple entities from the datastore in a batch. This starts an asynchronous fetch.
The parameters can be any mix of key-like structures, including:
Since fetching is asynchronous,
datastore exceptions
(DatastoreTimeoutException
, ConcurrentModificationException
, DatastoreFailureException
)
may be thrown when the Map is accessed.
keysOrEntities
- defines a possibly heterogeneous mixture of Key>, Ref>, native datastore Key, or registered
entity instances with valid id/parent fields.<E> Map<Key<E>,E> values(Object... keysOrEntities)
A convenient substitute for values(Iterable)
Objectify getObjectify()
Set<Class<?>> getLoadGroups()
<T> T fromEntity(com.google.appengine.api.datastore.Entity entity)
entity
- is a native datastore entity which has an appropriate kind registered in the ObjectifyFactory.<E> E now(Key<E> key)
Copyright © 2014. All rights reserved.