public interface Entity extends Map<String,Object>
entity type
as retrieved from a session
.
The current state of the entity is available by calling getState()
. Attribute values can be requested by:
Map.get(Object)
.getValue(String)
method.getValue(Attribute)
.getList(String)
.Modifier and Type | Interface and Description |
---|---|
static class |
Entity.PersistentState
All possible states of an entity.
|
Modifier and Type | Method and Description |
---|---|
Entity |
copy()
Copies this entity.
|
void |
copyFrom(Entity entity)
Copy the values of the given
entity to this entity. |
Collection<String> |
getAttributeNames()
Return a collection of the attributes declared for this entity.
|
EntityType |
getEntityType()
Return the type of this entity.
|
UUID |
getGid()
Returns the gid of this entity, if the session supports gids and the gid is already created, else
null . |
Identifier |
getIdentifier()
Return the identifier of this entity.
|
KeyValue |
getKeyValue()
Return the business key of this entity or
null if this entity is in state
NEW . |
List<Entity> |
getList(String name)
Return the value of the specified list attribute ("to N relation").
|
Session |
getSession()
Returns the session which was used to create or retrieve this entity.
|
Entity.PersistentState |
getState()
Return the
state of this entity. |
<T> T |
getValue(Attribute<T> attribute)
Return the value of the given attribute or
null . |
Object |
getValue(String name)
Return the value of the
attribute specified by the given name . |
boolean |
isReleased()
Return
true if this entity is released else false . |
boolean |
isValid()
Return
true if this entity is valid else false . |
void |
refresh()
Refresh the content of this entity with the one stored in the database.
|
void |
rollback()
Revert all attribute changes.
|
void |
rollbackWithRelations()
Reset all changes, including relations (i.e. this may rollback delete operations of entities which has been set
in relation to this entity).
|
<T> void |
setValue(Attribute<T> attribute,
T value)
Set the value of the attribute
attribute to value . |
<T> void |
setValue(String name,
T value)
Set the value of the attribute with
name to the given value . |
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
@ApiDoc(comment="Return the value of the attribute specified by the given name.", since="4.0.17") @Nullable Object getValue(@NotNull String name) throws de.espirit.or.ORException
attribute
specified by the given name
.
If no attribute
exists with the given name then the returned value is null
.name
- specifying the attribute to get the value forattribute
specified by the given name
or null
.de.espirit.or.ORException
@ApiDoc(comment=" Return the value of the specified list attribute (\"to N relation\").", since="4.0.55") @NotNull List<Entity> getList(String name) throws de.espirit.or.ORException
name
- The name of the list attribute.IllegalArgumentException
- if the attribut is no list attribute.de.espirit.or.ORException
@ApiDoc(comment="Return the value of the given attribute or null.", since="4.0.17") @Nullable <T> T getValue(Attribute<T> attribute) throws de.espirit.or.ORException
null
.attribute
- The attribute to get the value for.null
.de.espirit.or.ORException
@ApiDoc(comment="Set the value of the attribute with name to the given value.", since="4.0.17") <T> void setValue(@NotNull String name, @Nullable T value) throws de.espirit.or.ORException
name
to the given value
.name
- The attribute name.value
- The new value.IllegalArgumentException
- Ifname
denotes not a valid attribute or value
is an
incorrect type for this attributede.espirit.or.ORException
@ApiDoc(comment="Set the value of the attribute attribute to value.", since="4.0.17") <T> void setValue(@NotNull Attribute<T> attribute, @Nullable T value) throws de.espirit.or.ORException
attribute
to value
.de.espirit.or.ORException
@ApiDoc(comment="Return the type of this entity.", since="4.0.17") EntityType getEntityType()
@ApiDoc(comment="Return a collection of the attributes declared for this entity.", since="4.0.17") Collection<String> getAttributeNames()
getEntityType()
.EntityType.getAttributeNames()
.@ApiDoc(comment="Return true if this entity is valid else false.", since="4.0.17") boolean isValid() throws de.espirit.or.ORException
true
if this entity is valid else false
. An entity is valid if
and only if all values of its attributes are valid and itself is valid
according to the assigned validator
of its entity type
.true
if the entity is valid.de.espirit.or.ORException
@ApiDoc(comment="Refresh the content of this entity with the one stored in the database.", since="4.0.24") void refresh() throws de.espirit.or.ORException
de.espirit.or.ORException
@ApiDoc(comment="Return the identifier of this entity.", since="4.0.17") Identifier getIdentifier()
KeyValue
but each version must have an unique identifier
which is used to retrieve the version from the database. In the temporal context the identifier is a composed
primary key, it contains the key value of the entity and the system columns
valid from, valid to, release to
@ApiDoc(comment="Returns the gid of this entity, if the session supports gids and the gid is already created, else null.", since="5.0.100") @Nullable UUID getGid()
null
.
created
or modified legacy entities the gid
first becomes available after calling Session.commit()
null
if not created yet or the session
supports
no gids.@ApiDoc(comment="Return the business key of this entity or null if this entity is in state NEW.", since="4.0.17") @Nullable KeyValue getKeyValue()
null
if this entity is in state
NEW
.null
if the entity is new.@ApiDoc(comment="Return the state of this entity.", since="4.0.17") @NotNull Entity.PersistentState getState()
state
of this entity.Entity.PersistentState
@ApiDoc(comment="Return true if this entity is released else false.", since="4.0.17") boolean isReleased()
true
if this entity is released else false
. An entity is released if its
release to value is equals to Long.MAX_VALUE
. For non temporal data storage the returned value
is always false
.true
if the the entity is released.@ApiDoc(comment="Revert all attribute changes.", since="4.0.17") void rollback()
rollbackWithRelations()
,
Session.rollback()
@ApiDoc(comment="Reset all changes, including relations (i.e. this may rollback delete operations of entities which has been set in relation to this entity).", since="4.0.416") void rollbackWithRelations()
rollback()
,
Session.rollback()
@ApiDoc(comment="Returns the session which was used to create or retrieve this entity.", since="4.0.17") @NotNull Session getSession()
@ApiDoc(comment="Copies this entity.", since="4.0.55") Entity copy() throws de.espirit.or.ORException
state
Entity.PersistentState.NEW
.de.espirit.or.ORException
@ApiDoc(comment="Copy the values of the given entity to this entity.", since="4.0.17") void copyFrom(@NotNull Entity entity) throws de.espirit.or.ORException
entity
to this entity.
This will perform a shallow copy for related entities and a deep copy for aggregated
entities.entity
- Entity to copy values fromde.espirit.or.ORException
Copyright © 2021 e-Spirit AG. All Rights Reserved. Build 5.2.210210