- java.lang.Object
-
- io.github.mmm.entity.id.AbstractId<E,I,Long>
-
- io.github.mmm.entity.id.AbstractVersionId<E,I>
-
- Type Parameters:
E
- type of the identified entity.I
- type of theID
.
- All Implemented Interfaces:
Id<E>
- Direct Known Subclasses:
LongVersionId
,StringVersionId
,UuidVersionId
public abstract class AbstractVersionId<E,I> extends AbstractId<E,I,Long>
- Since:
- 1.0.0
-
-
Field Summary
-
Fields inherited from interface io.github.mmm.entity.id.Id
PROPERTY_ID, PROPERTY_VERSION, VERSION_LATEST, VERSION_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description AbstractVersionId(Class<E> type, Long version)
The constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Long
getVersion()
-
Methods inherited from class io.github.mmm.entity.id.AbstractId
equals, getFactory, getId, getIdAs, getType, getVersionAs, getVersionAsLong, getWithType, hashCode, parseUuid, toString, toString, withLatestVersion, withType, withVersion
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.github.mmm.entity.id.Id
getIdAsString, getVersionAsString
-
-
-
-
Constructor Detail
-
AbstractVersionId
public AbstractVersionId(Class<E> type, Long version)
The constructor.- Parameters:
type
- - seeAbstractId.getType()
.version
- - seegetVersion()
.
-
-
Method Detail
-
getVersion
public Long getVersion()
- Specified by:
getVersion
in interfaceId<E>
- Specified by:
getVersion
in classAbstractId<E,I,Long>
- Returns:
- the
version
of this entity. Whenever theEntity
gets updated (a modification is saved and the transaction is committed), this version is increased. Typically the version is aNumber
starting with0
for a newEntity
that is increased whenever a modification is committed. However, it may also be anInstant
. The version acts as a modification sequence for optimistic locking. On each update it will be verified that the version has not been increased already by another transaction. When linking anEntity
(Id
used as foreign key) the version can act as revision for auditing. If it isId.VERSION_LATEST
(null
) it points to the latest revision of theEntity
. Otherwise it points to a specific historic revision of theEntity
. Depending on the database technology (e.g. when using hibernate envers) the version and the revision can be semantically different. In such case aprimary key
can not be converted 1:1 as revisioned foreign keyId
.
-
-