Package de.espirit.or.schema
Interface Entity
An entity of a specific
entity type as retrieved from a session.
The current state of the entity is available by calling getState(). Attribute values can be requested by:
- The map interface method
Map.get(Object). - By the
getValue(String)method. - With the typesafe method
getValue(Attribute). - As list with
getList(String).
- Since:
- 4.0.17
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumAll possible states of an entity. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Copies this entity.voidCopy the values of the givenentityto this entity.Return a collection of the attributes declared for this entity.Return the type of this entity.@Nullable UUIDgetGid()Returns the gid of this entity, if the session supports gids and the gid is already created, elsenull.Return the identifier of this entity.@Nullable KeyValueReturn the business key of this entity ornullif this entity is in stateNEW.Return the value of the specified list attribute ("to N relation").@NotNull SessionReturns the session which was used to create or retrieve this entity.@NotNull Entity.PersistentStategetState()Return thestateof this entity.@Nullable ObjectReturn the value of theattributespecified by the givenname.<T> TReturn the value of the given attribute ornull.booleanReturntrueif this entity is released elsefalse.booleanisReleased(@NotNull String... languageAbbreviations) Returnstrueif this entity is currently released (not changed) and the given languages are marked as valid for the release state.booleanisValid()Returntrueif this entity is valid elsefalse.voidrefresh()Refresh the content of this entity with the one stored in the database.voidrollback()Revert all attribute changes.voidReset all changes, including relations (i.e. this may rollback delete operations of entities which has been set in relation to this entity).<T> voidSet the value of the attributeattributetovalue.<T> voidSet the value of the attribute withnameto the givenvalue.Methods inherited from interface java.util.Map
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
-
Method Details
-
getValue
@ApiDoc(comment="Return the value of the attribute specified by the given name.", since="4.0.17") @Nullable @Nullable Object getValue(@NotNull @NotNull String name) throws ORException Return the value of theattributespecified by the givenname. If noattributeexists with the given name then the returned value isnull.- Parameters:
name- specifying the attribute to get the value for- Returns:
- the value of the the
attributespecified by the givennameornull. - Throws:
ORException- Since:
- 4.0.17
-
getList
@ApiDoc(comment=" Return the value of the specified list attribute (\"to N relation\").", since="4.0.55") @NotNull @NotNull List<Entity> getList(String name) throws ORException Return the value of the specified list attribute ("to N relation").- Parameters:
name- The name of the list attribute.- Returns:
- The value of the attribute specified by name.
- Throws:
IllegalArgumentException- if the attribut is no list attribute.ORException- Since:
- 4.0.55
-
getValue
@ApiDoc(comment="Return the value of the given attribute or null.", since="4.0.17") @Nullable <T> T getValue(Attribute<T> attribute) throws ORException Return the value of the given attribute ornull.- Parameters:
attribute- The attribute to get the value for.- Returns:
- the value of the given attribute or
null. - Throws:
ORException- Since:
- 4.0.17
-
setValue
@ApiDoc(comment="Set the value of the attribute with name to the given value.", since="4.0.17") <T> void setValue(@NotNull @NotNull String name, @Nullable T value) throws ORException Set the value of the attribute withnameto the givenvalue.- Parameters:
name- The attribute name.value- The new value.- Throws:
IllegalArgumentException- Ifnamedenotes not a valid attribute orvalueis an incorrect type for this attributeORException- Since:
- 4.0.17
-
setValue
@ApiDoc(comment="Set the value of the attribute attribute to value.", since="4.0.17") <T> void setValue(@NotNull @NotNull Attribute<T> attribute, @Nullable T value) throws ORException Set the value of the attributeattributetovalue.- Throws:
ORException- Since:
- 4.0.17
-
getEntityType
Return the type of this entity.- Returns:
- The entity type of this entity.
- Since:
- 4.0.17
-
getAttributeNames
@ApiDoc(comment="Return a collection of the attributes declared for this entity.", since="4.0.17") Collection<String> getAttributeNames()Return a collection of the attributes declared for this entity. Shortcut forgetEntityType().EntityType.getAttributeNames().- Returns:
- List of valid attribute names.
- Since:
- 4.0.17
-
isValid
@ApiDoc(comment="Return true if this entity is valid else false.", since="4.0.17") boolean isValid() throws ORExceptionReturntrueif this entity is valid elsefalse. An entity is valid if and only if all values of its attributes are valid and itself is valid according to the assignedvalidatorof itsentity type.- Returns:
trueif the entity is valid.- Throws:
ORException- Since:
- 4.0.17
-
refresh
@ApiDoc(comment="Refresh the content of this entity with the one stored in the database.", since="4.0.24") void refresh() throws ORExceptionRefresh the content of this entity with the one stored in the database.- Throws:
ORException- Since:
- 4.0.24
-
getIdentifier
Return the identifier of this entity. In a temporal context an entity can have more than one version. All of the versions have the sameKeyValuebut 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 columnsvalid from, valid to, release to- Returns:
- The identifier of this entity.
- Since:
- 4.0.17
-
getGid
@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 @Nullable UUID getGid()Returns the gid of this entity, if the session supports gids and the gid is already created, elsenull.
Attention: For newlycreatedor modified legacy entities the gid first becomes available after callingSession.commit()- Returns:
- The gid of this entity or
nullif not created yet or thesessionsupports no gids. - Since:
- 5.0.100
-
getKeyValue
@ApiDoc(comment="Return the business key of this entity or null if this entity is in state NEW.", since="4.0.17") @Nullable @Nullable KeyValue getKeyValue()Return the business key of this entity ornullif this entity is in stateNEW.- Returns:
- The business key or
nullif the entity is new. - Since:
- 4.0.17
-
getState
@ApiDoc(comment="Return the state of this entity.", since="4.0.17") @NotNull @NotNull Entity.PersistentState getState()Return thestateof this entity.- Returns:
- The state of this entity.
- Since:
- 4.0.17
- See Also:
-
isReleased
@ApiDoc(comment="Return true if this entity is released else false.", since="4.0.17") boolean isReleased()Returntrueif this entity is released elsefalse. An entity is released if its release to value is equals toLong.MAX_VALUE. For non temporal data storage the returned value is alwaysfalse.- Returns:
trueif the entity is released.- Since:
- 4.0.17
-
isReleased
Returnstrueif this entity is currently released (not changed) and the given languages are marked as valid for the release state.- Parameters:
languageAbbreviations- The languages to check, empty means language independent release state.- Since:
- 5.2.250604
-
rollback
Revert all attribute changes.- Since:
- 4.0.17
- See Also:
-
rollbackWithRelations
@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()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
- See Also:
-
getSession
@ApiDoc(comment="Returns the session which was used to create or retrieve this entity.", since="4.0.17") @NotNull @NotNull Session getSession()Returns the session which was used to create or retrieve this entity.- Returns:
- The session instance used to create or retrieve this entity.
- Since:
- 4.0.17
-
copy
Copies this entity. This will create a shallow copy for related entities and a deep copy for aggregated entities. The returned entity will have thestateEntity.PersistentState.NEW.- Returns:
- A copy of this entity.
- Throws:
ORException- Since:
- 4.0.55
-
copyFrom
@ApiDoc(comment="Copy the values of the given entity to this entity.", since="4.0.17") void copyFrom(@NotNull @NotNull Entity entity) throws ORException Copy the values of the givenentityto this entity. This will perform a shallow copy for related entities and a deep copy for aggregated entities.- Parameters:
entity- Entity to copy values from- Throws:
ORException- Since:
- 4.0.17
-