Package com.google.appengine.api.datastore
See: Description
-
Interface Summary Interface Description AsyncDatastoreService An asynchronous version ofDatastoreService
.BaseDatastoreService Methods that are common betweenDatastoreService
andAsyncDatastoreService
.CallbackContext<T> Describes the context in which a callback runs.DatastoreConfig Deprecated UseDatastoreServiceConfig
instead.DatastoreService TheDatastoreService
provides synchronous access to a schema-less data storage system.IDatastoreServiceFactory This interface should be implemented by providers of theDatastoreService
and registered withcom.google.appengine.spi.ServiceFactoryFactory
.PreparedQuery Contains methods for fetching and returning entities from aQuery
.QueryResultIterable<T> A class that producesQueryResultIterator
s.QueryResultIterator<T> A class that iterates through the results of aQuery
QueryResultList<T> A list of results returned by executing aQuery
.Transaction Describes a logical unit of work to be performed against the datastore. -
Class Summary Class Description AdminDatastoreService An AsyncDatastoreService implementation that is pinned to a specific appId and namesapce.AdminDatastoreService.EntityBuilder AdminDatastoreService.KeyBuilder AdminDatastoreService.QueryBuilder Blob Blob
contains an array of bytes.Category A tag, ie a descriptive word or phrase.CloudDatastoreRemoteServiceConfig User-configurable global properties of Cloud Datastore.CloudDatastoreRemoteServiceConfig.AppId An App Engine application ID.CloudDatastoreRemoteServiceConfig.Builder Builder forCloudDatastoreRemoteServiceConfig
.CompositeIndexManager Composite index management operations needed by the datastore api.CompositeIndexUtils Static utilities for working with composite indexes.Cursor A cursor that represents a position in a query.DatastoreApiHelper Helper methods and constants shared by classes that implement the Java api on top of the datastore.DatastoreAttributes Attributes of a datastore.DatastoreServiceConfig User-configurable properties of the datastore.DatastoreServiceConfig.Builder Contains static creation methods forDatastoreServiceConfig
.DatastoreServiceFactory Creates DatastoreService implementations.DataTypeTranslator DataTypeTranslator
is a utility class for converting between the data store'sProperty
protocol buffers and the user-facing classes (String
,User
, etc.).DataTypeTranslator.ComparableByteArray A wrapper for abyte[]
that implementsComparable
.DataTypeUtils DataTypeUtils
presents a simpler interface that allows user-code to determine what Classes can safely be stored as properties in the data store.DeleteContext ConcreteCallbackContext
implementation that is specific to delete() callbacks.Email An e-mail address datatype.EmbeddedEntity A property value containing embedded entity properties (and optionally aKey
).Entities Utility functions and constants for entities.Entity Entity
is the fundamental unit of data storage.EntityProtoComparators Utilities for comparingEntityProto
.EntityProtoComparators.EntityProtoComparator A comparator forcom.google.storage.onestore.v3.OnestoreEntity.EntityProto
objects with the same ordering asEntityComparator
.EntityTranslator EntityTranslator
contains the logic to translate anEntity
into the protocol buffers that are used to pass it to the implementation of the API.ExtendableEntityUtil Internal class that provides utility methods for extendable entity objects.FetchOptions Describes the limit, offset, and chunk size to be applied when executing aPreparedQuery
.FetchOptions.Builder Contains static creation methods forFetchOptions
.FutureHelper Utilities for working withFutures
in the synchronous datastore api.GeoPt A geographical point, specified by float latitude and longitude coordinates.IDatastoreServiceFactoryProvider CreatesIDatastoreServiceFactory
implementations.IMHandle An instant messaging handle.Index A DatastoreIndex
definition.Index.Property An indexed property.IndexTranslator Helper class to translate betweenIndex
tocom.google.storage.onestore.v3.OnestoreEntity.Index
.Key The primary key for a datastore entity.KeyFactory This class enables direct creation ofKey
objects, both in the root entity group (no parent) and as the child of a given parent.KeyFactory.Builder Helper class that aids in the construction ofKeys
with ancestors.KeyRange Represents a range of unique datastore identifiers fromgetStart().getId()
togetEnd().getId()
inclusive.Link ALink
is a URL of limited length.PhoneNumber A human-readable phone number.PostalAddress A human-readable mailing address.PostLoadContext ConcreteCallbackContext
implementation that is specific to intercepted operations that loadEntities
, currently get and "query".PreGetContext ConcreteCallbackContext
implementation that is specific to intercepted get() operations.PreQueryContext ConcreteCallbackContext
implementation that is specific to intercepted queries.Projection A query projection.PropertyContainer A mutable property container.PropertyProjection A property projection.PutContext ConcreteCallbackContext
implementation that is specific to put() callbacks.Query Query.CompositeFilter AQuery.Filter
that combines several sub filters using aQuery.CompositeFilterOperator
.Query.Filter The base class for a query filter.Query.FilterPredicate AQuery.Filter
on a single property.Query.GeoRegion A geographic region intended for use in aQuery.StContainsFilter
.Query.GeoRegion.Circle A geographical region representing all points within a fixed distance from a central point, i.e., a circle.Query.GeoRegion.Rectangle A simple geographical region bounded by two latitude lines, and two longitude lines, i.e., a "rectangle".Query.SortPredicate SortPredicate is a data container that holds a single sort predicate.Query.StContainsFilter AQuery.Filter
representing a geo-region containment predicate.Rating A user-provided integer rating for a piece of content.RawValue A raw datastore value.ReadPolicy Policy for reads.ShortBlob ShortBlob
contains an array of bytes no longer thanDataTypeUtils.MAX_SHORT_BLOB_PROPERTY_LENGTH
.Text Text
wraps around a string of unlimited size.TransactionHelper TransactionHelper
enables the task queue API to serialize a datastore transaction without knowing the details of how it is implemented.TransactionOptions Describes options for transactions, passed at transaction creation time.TransactionOptions.Builder Contains static creation methods forTransactionOptions
. -
Enum Summary Enum Description CloudDatastoreRemoteServiceConfig.AppId.Location Locations for App Engine applications.DatastoreAttributes.DatastoreType Indicates the type of datastore being used.DatastoreService.KeyRangeState Indicates the state of aKeyRange
.IMHandle.Scheme Supported IM schemes.ImplicitTransactionManagementPolicy Describes the various policies the datastore can follow for implicit transaction management.Index.IndexState Indicates the state of theIndex
.Query.CompositeFilterOperator Operators supported byQuery.CompositeFilter
.Query.FilterOperator Operators supported byQuery.FilterPredicate
.Query.SortDirection SortDirection controls the order of a sort.ReadPolicy.Consistency Setting theConsistency
for reads allows you to decide whether freshness or availability is more important. -
Exception Summary Exception Description CommittedButStillApplyingException CommittedButStillApplyingException
is thrown when the write or transaction was committed, but some entities or index rows may not have been fully updated.DatastoreFailureException DatastoreFailureException
is thrown when any unknown error occurs while communicating with the data store.DatastoreNeedIndexException DatastoreNeedIndexException
is thrown when no matching index was found for a query requiring an index.DatastoreTimeoutException DatastoreTimeoutException
is thrown when a datastore operation times out.EntityNotFoundException EntityNotFoundException
is thrown when noEntity
with the specifiedKey
could be found.PreparedQuery.TooManyResultsException Indicates that too many results were found forPreparedQuery.asSingleEntity()
. -
Annotation Types Summary Annotation Type Description PostDelete Identifies a callback method to be invoked after anEntity
of any of the specified kinds is deleted from the datastore.PostLoad Identifies a callback method to be invoked after anEntity
of any of the specified kinds is loaded from the datastore.PostPut Identifies a callback method to be invoked after anEntity
of any of the specified kinds is written to the datastore.PreDelete Identifies a callback method to be invoked before anEntity
of any of the specified kinds is deleted from the datastore.PreGet Identifies a callback method to be invoked before anEntity
of any of the specified kinds is fetched from the datastore via a get() rpc.PrePut Identifies a callback method to be invoked before anEntity
of any of the specified kinds is written to the datastore.PreQuery Identifies a callback method to be invoked before aQuery
for any of the specified kinds is executed against the datastore.
Package com.google.appengine.api.datastore Description
A common pattern of usage is:
// Get a handle on the datastore itself DatastoreService datastore = DatastoreServiceFactory.getDatastoreService(); // Lookup data by known key name Entity userEntity = datastore.get(KeyFactory.createKey("UserInfo", email)); // Or perform a query Query query = new Query("Task"); query.addFilter("dueDate", Query.FilterOperator.LESS_THAN, today); for (Entity taskEntity : datastore.prepare(query).asIterable()) { if ("done".equals(taskEntity.getProperty("status"))) { datastore.delete(taskEntity); } else { taskEntity.setProperty("status", "overdue"); datastore.put(taskEntity); } }
This illustrates several basic points:
- The actual datastore itself is accessed through a
DatastoreService
object, produced from aDatastoreServiceFactory
. - The unit of storage is the
Entity
object, which are of named kinds ("UserInfo" and "Task" above). - Entities have a
Key
value, which can be created by aKeyFactory
to retrieve a specific known entity. If the key is not readily determined, thenQuery
objects can be used to retrieve one Entity, multiple as a list,Iterable
, orIterator
, or to retrieve the count of matching entities. - Entities have named properties, the values of which may be basic types or collections of basic types. Richer objects, of course, may be stored if serialized as byte arrays, although that may prevent effective querying by those properties.
- Entities may be associated in a tree structure; the
Query
in the snippet above searches only for Task entities associated with a specific UserInfo entity, and then filters those for Tasks due before today.
In production, non-trivial queries cannot be performed until one or more indexes have been
built to ensure that the individual queries can be processed efficiently. You can specify the set
of indexes your application requires in a WEB-INF/datastore-indexes.xml
file, or they can
be generated automatically as you test your application in the Development Server. If a query
requires an index that cannot be found, a DatastoreNeedIndexException
will be thrown at runtime.
Although Google App Engine allows many versions of your application to be accessible, there is only one datastore for your application, shared by all versions. Similarly, the set of indexes is shared by all application versions.
Application authors may also consider using either of the provided JDO or JPA interfaces to the datastore.