Class Entity
- All Implemented Interfaces:
Serializable
,Cloneable
Entity
is the fundamental unit of data storage. It has an immutable identifier (contained
in the Key
) object, a reference to an optional parent Entity
, a kind (represented
as an arbitrary string), and a set of zero or more typed properties.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A reserved property name used to refer to the key of the entity.static final String
A reserved property name used to refer to the scatter property of the entity.static final String
A reserved property name used to report an entity group's version. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a newEntity
uniquely identified by the providedKey
.Create a newEntity
with the specified kind and no parentEntity
.Create a newEntity
with the specified kind and ID and no parentEntity
.Create a newEntity
with the specified kind and ID and parentEntity
.Create a newEntity
with the specified kind and parentEntity
.Create a newEntity
with the specified kind and key name and no parentEntity
.Create a newEntity
with the specified kind, key name, and parentEntity
. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a shallow copy of thisEntity
instance.boolean
TwoEntity
objects are considered equal if they refer to the same entity (i.e. theirKey
objects match).getAppId()
Returns the identifier of the application that owns thisEntity
.getKey()
Returns theKey
that represents thisEntity
.getKind()
Returns a logical type that is associated with thisEntity
.Returns the namespace of the application/namespace that owns thisEntity
.@Nullable Key
Get aKey
that corresponds to this the parentEntity
of thisEntity
.int
hashCode()
void
setPropertiesFrom
(Entity src) toString()
Methods inherited from class com.google.appengine.api.datastore.PropertyContainer
getProperties, getProperty, hasProperty, isUnindexedProperty, removeProperty, setIndexedProperty, setPropertiesFrom, setProperty, setUnindexedProperty
-
Field Details
-
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:
-
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:
-
VERSION_RESERVED_PROPERTY
A reserved property name used to report an entity group's version.- See Also:
-
-
Constructor Details
-
Entity
-
Entity
-
Entity
Create a newEntity
with the specified kind and key name and no parentEntity
. The instantiatedEntity
will have a completeKey
when this constructor returns. TheKey's
name
field will be set to the value ofkeyName
.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(kind, keyName))
. -
Entity
Create a newEntity
with the specified kind and ID and no parentEntity
. The instantiatedEntity
will have a completeKey
when this constructor returns. TheKey's
id
field 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
KeyRange
obtained 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
Create a newEntity
with the specified kind, key name, and parentEntity
. The instantiatedEntity
will have a completeKey
when this constructor returns. TheKey's
name
field will be set to the value ofkeyName
.This constructor is syntactic sugar for
new Entity(KeyFactory.createKey(parent, kind, keyName))
. -
Entity
Create a newEntity
with the specified kind and ID and parentEntity
. The instantiatedEntity
will have a completeKey
when this constructor returns. TheKey's
id
field 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
KeyRange
obtained 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))
. -
Entity
Create a newEntity
uniquely identified by the providedKey
. Creating an entity for the purpose of insertion (as opposed to update) with a key that has itsid
field set is strongly discouraged unless the key was returned by aKeyRange
.- See Also:
-
-
Method Details
-
equals
TwoEntity
objects are considered equal if they refer to the same entity (i.e. theirKey
objects match). -
getKey
Returns theKey
that represents thisEntity
. If the entity has not yet been saved (e.g. viaDatastoreService.put
), thisKey
will not be fully specified and cannot be used for certain operations (likeDatastoreService.get
). Once theEntity
has been saved, itsKey
will be updated to be fully specified. -
getKind
Returns a logical type that is associated with thisEntity
. This is simply a convenience method that forwards to theKey
for thisEntity
. -
getParent
Get aKey
that corresponds to this the parentEntity
of thisEntity
. This is simply a convenience method that forwards to theKey
for thisEntity
. -
hashCode
public int hashCode() -
toString
-
getAppId
Returns the identifier of the application that owns thisEntity
. This is simply a convenience method that forwards to theKey
for thisEntity
. -
getNamespace
Returns the namespace of the application/namespace that owns thisEntity
. This is simply a convenience method that forwards to theKey
for thisEntity
. -
clone
Returns a shallow copy of thisEntity
instance.Collection
properties 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
-