ID
- is the type of the primary key
.@MappedSuperclass public abstract class AbstractJpaEntity<ID> extends AbstractRevisionedEntity<ID> implements PersistenceEntity<ID>
Modifier and Type | Field and Description |
---|---|
private static long |
serialVersionUID
UID for serialization.
|
STATE_DETACHED, STATE_MANAGED, STATE_NEW, STATE_REMOVED
LATEST_REVISION
Constructor and Description |
---|
AbstractJpaEntity()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
ID |
getId()
ATTENTION:
If your ID is not generated , you need to override this method. |
int |
getModificationCounter()
This method gets the current modification-counter of this entity.
|
Number |
getRevision()
This method gets the revision of this entity.
|
equals, hashCode, setRevision, toString
setId, setModificationCounter
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
setId, setModificationCounter
private static final long serialVersionUID
public ID getId()
generated
, you need to override this method. In this case you
can also override AbstractGenericEntity.setId(Object)
to change the visibility to public. 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 GenericEntity<ID>
getId
in interface AttributeReadId<ID>
getId
in class AbstractGenericEntity<ID>
null
if the object is
new
and no ID has manually been assigned.public int getModificationCounter()
saved
, this counter will be increased. The
initial value after construction is 0
. 0
.getModificationCounter
in interface GenericEntity<ID>
getModificationCounter
in class AbstractGenericEntity<ID>
Version
public Number getRevision()
latest
revision
of an entity will always return null
. Otherwise this object is a
historic entity and it will be read-only so modifications are NOT permitted.getRevision
in interface RevisionedEntity<ID>
getRevision
in class AbstractRevisionedEntity<ID>
RevisionedEntity.LATEST_REVISION
(null
) if this is the latest revision.Copyright © 2001–2014 mmm-Team. All rights reserved.