|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Objectify
This is the main "business end" of Objectify. It lets you get(), put(), delete(), and query() your typed POJO entities.
You can create an Objectify
instance using ObjectifyFactory.begin()
or ObjectifyFactory.beginTransaction()
. A transaction (or lack thereof)
will be associated with the instance; by using multiple instances, you can interleave
calls between several different transactions.
Method Summary | ||
---|---|---|
AsyncObjectify |
async()
Obtain the asynchronous version of the Objectify interface. |
|
|
delete(java.lang.Class<T> clazz,
long id)
A convenience method, shorthand for creating a key and deleting it. |
|
|
delete(java.lang.Class<T> clazz,
java.lang.String name)
A convenience method, shorthand for creating a key and deleting it. |
|
void |
delete(java.lang.Iterable<?> keysOrEntities)
Deletes the specified entities in a parallel batch operation. |
|
void |
delete(java.lang.Object... keysOrEntities)
Deletes the specified entity. |
|
|
find(java.lang.Class<? extends T> clazz,
long id)
Same as get(Class, long) but returns null instead of throwing NotFoundException |
|
|
find(java.lang.Class<? extends T> clazz,
java.lang.String name)
Same as get(Class, name) but returns null instead of throwing NotFoundException |
|
|
find(Key<? extends T> key)
Same as get(Key) but returns null instead of throwing NotFoundException |
|
|
get(java.lang.Class<? extends T> clazz,
java.lang.Iterable<S> idsOrNames)
A convenience method that prevents you from having to assemble all the Keys yourself and calling get(Iterable<Key>) . |
|
|
get(java.lang.Class<? extends T> clazz,
long id)
A convenience method, shorthand for creating a key and calling get() |
|
|
get(java.lang.Class<? extends T> clazz,
S... idsOrNames)
Convenient varargs alias for get(Class>, Iterable>) |
|
|
get(java.lang.Class<? extends T> clazz,
java.lang.String name)
A convenience method, shorthand for creating a key and calling get() |
|
|
get(java.lang.Iterable<? extends Key<? extends T>> keys)
Performs a parallel batch get, returning your entities. |
|
|
get(Key<? extends T>... keys)
Varargs version of get(Iterable) |
|
|
get(Key<? extends T> key)
Gets one instance of your entity. |
|
com.google.appengine.api.datastore.DatastoreService |
getDatastore()
Obtain a DatastoreService with parameters roughly equivalent to this Objectify instance. |
|
ObjectifyFactory |
getFactory()
Obtain the ObjectifyFactory from which this Objectify instance was created. |
|
com.google.appengine.api.datastore.Transaction |
getTxn()
Get the underlying transaction object associated with this Objectify instance. |
|
|
put(java.lang.Iterable<? extends T> objs)
Saves multiple entities to the datastore in a single parallel batch operation. |
|
|
put(T... objs)
Convenient varargs alias for put(Iterable>) |
|
|
put(T obj)
Puts an entity in the datastore. |
|
|
query()
Create a typesafe query across all kinds of entities. |
|
|
query(java.lang.Class<T> clazz)
Create a typesafe query across one specific kind of entity. |
Method Detail |
---|
<T> java.util.Map<Key<T>,T> get(java.lang.Iterable<? extends Key<? extends T>> keys)
Performs a parallel batch get, returning your entities. This is faster and more efficient than fetching entities one at a time.
You can fetch entities of many different kinds in a single call. Entities not present in the datastore will be absent from the returned map. Otherwise, the iteration order of the result will match the order in the parameter.
keys
- are the keys to fetch; you can mix and match the types of objects.
keys
argument.
A empty map is returned if no keys are found in the datastore.DatastoreService.get(Iterable)
<T> java.util.Map<Key<T>,T> get(Key<? extends T>... keys)
Varargs version of get(Iterable)
<T> T get(Key<? extends T> key) throws NotFoundException
Gets one instance of your entity.
NotFoundException
- if the key does not exist in the datastoreDatastoreService.get(Key)
<T> T get(java.lang.Class<? extends T> clazz, long id) throws NotFoundException
A convenience method, shorthand for creating a key and calling get()
NotFoundException
- if the key does not exist in the datastore<T> T get(java.lang.Class<? extends T> clazz, java.lang.String name) throws NotFoundException
A convenience method, shorthand for creating a key and calling get()
NotFoundException
- if the key does not exist in the datastore<S,T> java.util.Map<S,T> get(java.lang.Class<? extends T> clazz, java.lang.Iterable<S> idsOrNames)
A convenience method that prevents you from having to assemble all the Keys
yourself and calling get(Iterable<Key>)
.
Note that unlike the standard batch get method, this method only gets a homogeneous set of objects.
idsOrNames
- must be of type Iterablejava.lang.IllegalArgumentException
- if ids is not Iterable<S,T> java.util.Map<S,T> get(java.lang.Class<? extends T> clazz, S... idsOrNames)
<T> T find(Key<? extends T> key)
get(Key)
but returns null instead of throwing NotFoundException
<T> T find(java.lang.Class<? extends T> clazz, long id)
get(Class, long)
but returns null instead of throwing NotFoundException
<T> T find(java.lang.Class<? extends T> clazz, java.lang.String name)
get(Class, name)
but returns null instead of throwing NotFoundException
<T> Key<T> put(T obj)
Puts an entity in the datastore.
If your entity has a null Long id, a fresh id will be generated and a new entity will be created in the database. If your entity already has an id (either long, Long, or String) value, any existing entity in the datastore with that id will be overwritten.
Generated ids are stored in the entity itself. If you put() an entity with a null Long id, it will be set before the method returns.
obj
- must be an object of a registered entity type.
DatastoreService.put(com.google.appengine.api.datastore.Entity)
<T> java.util.Map<Key<T>,T> put(java.lang.Iterable<? extends T> objs)
Saves multiple entities to the datastore in a single parallel batch operation.
All the rules regarding generated ids in put()
apply.
Note that the iteration order of the return value will be the same as the order of the parameter.
objs
- must all be objects of registered entity type
DatastoreService.put(Iterable)
<T> java.util.Map<Key<T>,T> put(T... objs)
void delete(java.lang.Object... keysOrEntities)
keysOrEntities
- can be Key>s, datastore Keys, or pojo entities.
If it includes entities, only the id fields are relevant.void delete(java.lang.Iterable<?> keysOrEntities)
keysOrEntities
- can contain any mix of Key>, datastore Key, or pojo
entities. They need not be of the same type. If a pojo is used, only its
id fields are relevant.DatastoreService.delete(Iterable)
<T> void delete(java.lang.Class<T> clazz, long id)
<T> void delete(java.lang.Class<T> clazz, java.lang.String name)
<T> Query<T> query()
Create a typesafe query across all kinds of entities.
<T> Query<T> query(java.lang.Class<T> clazz)
Create a typesafe query across one specific kind of entity.
com.google.appengine.api.datastore.Transaction getTxn()
Get the underlying transaction object associated with this Objectify instance.
Note that this is *not* the same as DatastoreService.getCurrentTransaction()
,
which uses implicit transaction management. Objectify does not use implicit (thread
local) transactions.
com.google.appengine.api.datastore.DatastoreService getDatastore()
Obtain a DatastoreService with parameters roughly equivalent to this Objectify instance.
This should not normally be necessary. It allows you to work with raw Entity objects, allocate ids, and examine thread local transactions.
Note that Objectify does not actually use this DatastoreService in any way; all requests go through an AsyncDatastoreService. Also, even Google's DatastoreService implementation is just a facade around AsyncDatastoreService.
ObjectifyFactory getFactory()
AsyncObjectify async()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |