Package com.google.appengine.api.datastore
See: Description
-
Interface Summary Interface Description AsyncDatastoreService An asynchronous version ofDatastoreService.BaseDatastoreService Methods that are common betweenDatastoreServiceandAsyncDatastoreService.CallbackContext<T> Describes the context in which a callback runs.DatastoreConfig Deprecated UseDatastoreServiceConfiginstead.DatastoreService TheDatastoreServiceprovides synchronous access to a schema-less data storage system.IDatastoreServiceFactory This interface should be implemented by providers of theDatastoreServiceand registered withcom.google.appengine.spi.ServiceFactoryFactory.PreparedQuery Contains methods for fetching and returning entities from aQuery.QueryResultIterable<T> A class that producesQueryResultIterators.QueryResultIterator<T> A class that iterates through the results of aQueryQueryResultList<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 Blobcontains 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 DataTypeTranslatoris a utility class for converting between the data store'sPropertyprotocol buffers and the user-facing classes (String,User, etc.).DataTypeTranslator.ComparableByteArray A wrapper for abyte[]that implementsComparable.DataTypeUtils DataTypeUtilspresents a simpler interface that allows user-code to determine what Classes can safely be stored as properties in the data store.DeleteContext ConcreteCallbackContextimplementation 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 Entityis the fundamental unit of data storage.EntityProtoComparators Utilities for comparingEntityProto.EntityProtoComparators.EntityProtoComparator A comparator forcom.google.storage.onestore.v3.OnestoreEntity.EntityProtoobjects with the same ordering asEntityComparator.EntityTranslator EntityTranslatorcontains the logic to translate anEntityinto 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 withFuturesin the synchronous datastore api.GeoPt A geographical point, specified by float latitude and longitude coordinates.IDatastoreServiceFactoryProvider CreatesIDatastoreServiceFactoryimplementations.IMHandle An instant messaging handle.Index A DatastoreIndexdefinition.Index.Property An indexed property.IndexTranslator Helper class to translate betweenIndextocom.google.storage.onestore.v3.OnestoreEntity.Index.Key The primary key for a datastore entity.KeyFactory This class enables direct creation ofKeyobjects, 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 ofKeyswith ancestors.KeyRange Represents a range of unique datastore identifiers fromgetStart().getId()togetEnd().getId()inclusive.Link ALinkis a URL of limited length.PhoneNumber A human-readable phone number.PostalAddress A human-readable mailing address.PostLoadContext ConcreteCallbackContextimplementation that is specific to intercepted operations that loadEntities, currently get and "query".PreGetContext ConcreteCallbackContextimplementation that is specific to intercepted get() operations.PreQueryContext ConcreteCallbackContextimplementation that is specific to intercepted queries.Projection A query projection.PropertyContainer A mutable property container.PropertyProjection A property projection.PutContext ConcreteCallbackContextimplementation that is specific to put() callbacks.Query Query.CompositeFilter AQuery.Filterthat combines several sub filters using aQuery.CompositeFilterOperator.Query.Filter The base class for a query filter.Query.FilterPredicate AQuery.Filteron 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.Filterrepresenting 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 ShortBlobcontains an array of bytes no longer thanDataTypeUtils.MAX_SHORT_BLOB_PROPERTY_LENGTH.Text Textwraps around a string of unlimited size.TransactionHelper TransactionHelperenables 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 theConsistencyfor reads allows you to decide whether freshness or availability is more important. -
Exception Summary Exception Description CommittedButStillApplyingException CommittedButStillApplyingExceptionis thrown when the write or transaction was committed, but some entities or index rows may not have been fully updated.DatastoreFailureException DatastoreFailureExceptionis thrown when any unknown error occurs while communicating with the data store.DatastoreNeedIndexException DatastoreNeedIndexExceptionis thrown when no matching index was found for a query requiring an index.DatastoreTimeoutException DatastoreTimeoutExceptionis thrown when a datastore operation times out.EntityNotFoundException EntityNotFoundExceptionis thrown when noEntitywith the specifiedKeycould 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 anEntityof any of the specified kinds is deleted from the datastore.PostLoad Identifies a callback method to be invoked after anEntityof any of the specified kinds is loaded from the datastore.PostPut Identifies a callback method to be invoked after anEntityof any of the specified kinds is written to the datastore.PreDelete Identifies a callback method to be invoked before anEntityof any of the specified kinds is deleted from the datastore.PreGet Identifies a callback method to be invoked before anEntityof any of the specified kinds is fetched from the datastore via a get() rpc.PrePut Identifies a callback method to be invoked before anEntityof any of the specified kinds is written to the datastore.PreQuery Identifies a callback method to be invoked before aQueryfor 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
DatastoreServiceobject, produced from aDatastoreServiceFactory. - The unit of storage is the
Entityobject, which are of named kinds ("UserInfo" and "Task" above). - Entities have a
Keyvalue, which can be created by aKeyFactoryto retrieve a specific known entity. If the key is not readily determined, thenQueryobjects 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
Queryin 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.