- 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 LonggetVersion()-
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:
getVersionin interfaceId<E>- Specified by:
getVersionin classAbstractId<E,I,Long>- Returns:
- the
versionof this entity. Whenever theEntitygets updated (a modification is saved and the transaction is committed), this version is increased. Typically the version is aNumberstarting with0for a newEntitythat 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(Idused 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 keycan not be converted 1:1 as revisioned foreign keyId.
-
-