E
- the generic type of the identified entity.public class OrientId<E> extends AbstractId<E>
Id
for a native ORID
.Modifier and Type | Field and Description |
---|---|
private com.orientechnologies.orient.core.id.ORID |
orid |
private Class<E> |
type |
private UUID |
uuid |
private long |
version |
ID_UUID, VERSION_LATEST, VERSION_SEPARATOR
Modifier | Constructor and Description |
---|---|
protected |
OrientId(Class<E> type,
UUID uuid,
com.orientechnologies.orient.core.id.ORID orid,
long version)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
long |
getId() |
com.orientechnologies.orient.core.id.ORID |
getOrid() |
Class<E> |
getType() |
UUID |
getUuid()
Gets the primary key as
UUID . |
long |
getVersion() |
static <E> OrientId<E> |
of(Class<E> type,
com.orientechnologies.orient.core.id.ORID orid,
long version) |
static <E> OrientId<E> |
of(Class<E> type,
String idAsString) |
static <E> OrientId<E> |
of(Class<E> type,
UUID uuid,
long version) |
String |
toString()
|
Id<E> |
withLatestVersion() |
OrientId<E> |
withType(Class<?> newType) |
equals, hashCode, parseUuid, toString
private final com.orientechnologies.orient.core.id.ORID orid
private final UUID uuid
private final long version
public long getId()
Entity
as long
value. It is only unique for a
particular type
of an entity. May also be Id.ID_UUID
.public UUID getUuid()
Id
UUID
. Most data stores will use a long
provided by
Id.getId()
. However a UUID
can be used in the following scenarios:
UUID
s natively as primary key (e.g. apache cassandra supports this). In
such case Id.getId()
will always return Id.ID_UUID
and Id.getUuid()
holds the actual
primary key.UUID
to the
entity on the client and link it via such ID. On the server-side the actual UUID
based Id
can then
be replaced with the actual ID
while persisting the data.null
.Entity
as UUID
value or null
if
Id.getId()
is used.public OrientId<E> withType(Class<?> newType)
newType
- the value of Id.getType()
. Exact type should actually be Class
<E> but this
prevents simple usage. As the type
can not actually be changed with this method, this
should be fine.Id
ensured to carry the type
.public Id<E> withLatestVersion()
Id
with a version
of Id.VERSION_LATEST
e.g. to use the Id
as regular foreign key (pointing to the latest revision and not a historic revision).public long getVersion()
version
of this entity. Whenever the Entity
gets updated (a modification is saved and
the transaction is committed), this counter is increased. The initial value of a new EntityBean
is
0
. The version acts as a modification counter for optimistic locking. On each update it will be
verified that the version has not been increased already by another transaction. When linking an
Entity
(Id
used as foreign key) the version can act as revision for auditing. If it is
Id.VERSION_LATEST
it points to the latest revision of the Entity
. Otherwise it points to a
specific historic revision of the Entity
. Depending on the database technology (e.g. when using
hibernate envers) the version and the revision can be semantically different. In such case a
primary key
can not directly be used as revisioned foreign key Id
.public com.orientechnologies.orient.core.id.ORID getOrid()
ORID
.public String toString()
Datatype
String
representation of this Datatype
. While the general contract of
Object.toString()
is very weak and mainly used for debugging, the contract here is very strong. The
returned String
has to be suitable for end-users and official output to any kind of sink. NlsMessage
for
this purpose and implement NlsObject
if you want to support I18N/L10N.toString
in interface Id<E>
toString
in interface Datatype
toString
in class AbstractId<E>
String
representation of this Id
. Will consist of object-id
,
type
and revision
separated with a specific separator. Segments
that are null
will typically be omitted in the String
representation.public static <E> OrientId<E> of(Class<E> type, String idAsString)
E
- the generic type of the identified entity.type
- - see getType()
.idAsString
- the string representation of the ID
.OrientId
.public static <E> OrientId<E> of(Class<E> type, UUID uuid, long version)
E
- the generic type of the identified entity.type
- - see getType()
.uuid
- - see getUuid()
.version
- - see getVersion()
.OrientId
.public static <E> OrientId<E> of(Class<E> type, com.orientechnologies.orient.core.id.ORID orid, long version)
E
- the generic type of the identified entity.type
- - see getType()
.orid
- - see getOrid()
.version
- - see getVersion()
.OrientId
.Copyright © 2001–2016 mmm-Team. All rights reserved.