Class Entity
- java.lang.Object
-
- com.google.appengine.api.datastore.PropertyContainer
-
- com.google.appengine.api.datastore.Entity
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable
public final class Entity extends PropertyContainer implements java.lang.Cloneable
Entityis the fundamental unit of data storage. It has an immutable identifier (contained in theKey) object, a reference to an optional parentEntity, a kind (represented as an arbitrary string), and a set of zero or more typed properties.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringKEY_RESERVED_PROPERTYA reserved property name used to refer to the key of the entity.static java.lang.StringSCATTER_RESERVED_PROPERTYA reserved property name used to refer to the scatter property of the entity.static java.lang.StringVERSION_RESERVED_PROPERTYA reserved property name used to report an entity group's version.
-
Constructor Summary
Constructors Constructor and Description Entity(Key key)Create a newEntityuniquely identified by the providedKey.Entity(java.lang.String kind)Create a newEntitywith the specified kind and no parentEntity.Entity(java.lang.String kind, Key parent)Create a newEntitywith the specified kind and parentEntity.Entity(java.lang.String kind, long id)Create a newEntitywith the specified kind and ID and no parentEntity.Entity(java.lang.String kind, long id, Key parent)Create a newEntitywith the specified kind and ID and parentEntity.Entity(java.lang.String kind, java.lang.String keyName)Create a newEntitywith the specified kind and key name and no parentEntity.Entity(java.lang.String kind, java.lang.String keyName, Key parent)Create a newEntitywith the specified kind, key name, and parentEntity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Entityclone()Returns a shallow copy of thisEntityinstance.booleanequals(java.lang.Object object)TwoEntityobjects are considered equal if they refer to the same entity (i.e.java.lang.StringgetAppId()Returns the identifier of the application that owns thisEntity.KeygetKey()Returns theKeythat represents thisEntity.java.lang.StringgetKind()Returns a logical type that is associated with thisEntity.java.lang.StringgetNamespace()Returns the namespace of the application/namespace that owns thisEntity.KeygetParent()Get aKeythat corresponds to this the parentEntityof thisEntity.inthashCode()voidsetPropertiesFrom(Entity src)java.lang.StringtoString()-
Methods inherited from class com.google.appengine.api.datastore.PropertyContainer
getProperties, getProperty, hasProperty, isUnindexedProperty, removeProperty, setIndexedProperty, setPropertiesFrom, setProperty, setUnindexedProperty
-
-
-
-
Field Detail
-
KEY_RESERVED_PROPERTY
public static final java.lang.String KEY_RESERVED_PROPERTY
A reserved property name used to refer to the key of the entity. This string can be used for filtering and sorting by the entity key itself.- See Also:
- Constant Field Values
-
SCATTER_RESERVED_PROPERTY
public static final java.lang.String SCATTER_RESERVED_PROPERTY
A reserved property name used to refer to the scatter property of the entity. Used for finding split points (e.g. for mapping over a kind).- See Also:
- Constant Field Values
-
VERSION_RESERVED_PROPERTY
public static final java.lang.String VERSION_RESERVED_PROPERTY
A reserved property name used to report an entity group's version.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Entity
public Entity(java.lang.String kind)
-
Entity
public Entity(java.lang.String kind, Key parent)
-
Entity
public Entity(java.lang.String kind, java.lang.String keyName)Create a newEntitywith the specified kind and key name and no parentEntity. The instantiatedEntitywill have a completeKeywhen this constructor returns. TheKey'snamefield will be set to the value ofkeyName.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(kind, keyName)).
-
Entity
public Entity(java.lang.String kind, long id)Create a newEntitywith the specified kind and ID and no parentEntity. The instantiatedEntitywill have a completeKeywhen this constructor returns. TheKey'sidfield will be set to the value ofid.Creating an entity for the purpose of insertion (as opposed to update) with this constructor is discouraged unless the id was obtained from a key returned by a
KeyRangeobtained fromAsyncDatastoreService.allocateIds(String, long)orDatastoreService.allocateIds(String, long)for the same kind.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(kind, id)).
-
Entity
public Entity(java.lang.String kind, java.lang.String keyName, Key parent)Create a newEntitywith the specified kind, key name, and parentEntity. The instantiatedEntitywill have a completeKeywhen this constructor returns. TheKey'snamefield will be set to the value ofkeyName.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(parent, kind, keyName)).
-
Entity
public Entity(java.lang.String kind, long id, Key parent)Create a newEntitywith the specified kind and ID and parentEntity. The instantiatedEntitywill have a completeKeywhen this constructor returns. TheKey'sidfield will be set to the value ofid.Creating an entity for the purpose of insertion (as opposed to update) with this constructor is discouraged unless the id was obtained from a key returned by a
KeyRangeobtained fromAsyncDatastoreService.allocateIds(Key, String, long)orDatastoreService.allocateIds(Key, String, long)for the same parent and kind.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(parent, kind, id)).
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object object)
TwoEntityobjects are considered equal if they refer to the same entity (i.e. theirKeyobjects match).- Overrides:
equalsin classjava.lang.Object
-
getKey
public Key getKey()
Returns theKeythat represents thisEntity. If the entity has not yet been saved (e.g. viaDatastoreService.put), thisKeywill not be fully specified and cannot be used for certain operations (likeDatastoreService.get). Once theEntityhas been saved, itsKeywill be updated to be fully specified.
-
getKind
public java.lang.String getKind()
Returns a logical type that is associated with thisEntity. This is simply a convenience method that forwards to theKeyfor thisEntity.
-
getParent
public Key getParent()
Get aKeythat corresponds to this the parentEntityof thisEntity. This is simply a convenience method that forwards to theKeyfor thisEntity.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getAppId
public java.lang.String getAppId()
Returns the identifier of the application that owns thisEntity. This is simply a convenience method that forwards to theKeyfor thisEntity.
-
getNamespace
public java.lang.String getNamespace()
Returns the namespace of the application/namespace that owns thisEntity. This is simply a convenience method that forwards to theKeyfor thisEntity.
-
clone
public Entity clone()
Returns a shallow copy of thisEntityinstance.Collectionproperties are cloned as anArrayList, the type returned from the datastore. Instances of mutable datastore types are cloned as well. Instances of all other types are reused.- Returns:
- a shallow copy of this
Entity
-
setPropertiesFrom
public void setPropertiesFrom(Entity src)
-
-