ID - is the type of the primary key.public interface GenericEntity<ID> extends AttributeReadId<ID>, Entity
Pojo. GenericEntity is identified by a primary key.GenericEntity has a modification counter for optimistic
locking (even though not strictly required - you could statically return 0).persistence entities (independent from their
actual state such as managed). On the other hand in the higher
layers instances always need to be TransferObjects. Our
recommendation is to
convert persistent entities into entity
transfer-objects when exposing functionality in the API of the logic layer.Entity| Modifier and Type | Method and Description |
|---|---|
ID |
getId()
This method gets the unique identifier (primary key) of this entity.
|
int |
getModificationCounter()
This method gets the current modification-counter of this entity.
|
ID getId()
Long as datatype for IDs. String-based business-oriented identifier it is best practice to use a
Long as primary key and add the business identifier as additional field (with a unique
constraint). This way references to the entity will be a lot more compact and improve your performance in
JOINs or the like. However, there may be reasons to use other datatypes for the ID. In any case the unique ID should be an immutable java-object that can be rebuild
from its string-representation. Datatype for it. If it can easily be mapped to a Long
value you can still use Long here and provide a transient getter method that returns the your
custom Datatype from the Long.getId in interface AttributeReadId<ID>null if the object is
new and no ID has manually been assigned.int getModificationCounter()
saved, this counter will be increased. The
initial value after construction is 0. 0.VersionCopyright © 2001–2015 mmm-Team. All rights reserved.