Package org.omnifaces.persistence.model
Class TimestampedBaseEntity<I extends Comparable<I> & Serializable>
java.lang.Object
org.omnifaces.persistence.model.BaseEntity<I>
org.omnifaces.persistence.model.TimestampedBaseEntity<I>
- Type Parameters:
I
- The generic ID type.
- All Implemented Interfaces:
Serializable
,Comparable<BaseEntity<I>>
,Identifiable<I>
,Timestamped
- Direct Known Subclasses:
VersionedBaseEntity
@MappedSuperclass
public abstract class TimestampedBaseEntity<I extends Comparable<I> & Serializable>
extends BaseEntity<I>
implements Timestamped
Mapped superclass for timestamped entity.
It extends from BaseEntity
.
It specifies two timestamp columns, named "created" and "lastModified".
The Id
column needs to be manually taken care of.
On pre persist, the both columns will be set to current timestamp.
On pre update, the "lastModified" column will be set to current timestamp, unless skipAdjustLastModified()
is called beforehand.
- Author:
- Bauke Scholtz
- See Also:
-
Field Summary
Fields inherited from interface org.omnifaces.persistence.model.Identifiable
ID
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
setCreated
(Instant created) void
setLastModified
(Instant lastModified) void
Invoke this method if you need to skip adjusting the "last modified" timestamp during any update event on this instance.Methods inherited from class org.omnifaces.persistence.model.BaseEntity
compareTo, compareTo, equals, equals, hashCode, hashCode, toString, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.omnifaces.persistence.model.Identifiable
getId, setId
-
Constructor Details
-
TimestampedBaseEntity
public TimestampedBaseEntity()
-
-
Method Details
-
onPrePersist
public void onPrePersist() -
onPreUpdate
public void onPreUpdate() -
skipAdjustLastModified
public void skipAdjustLastModified()Invoke this method if you need to skip adjusting the "last modified" timestamp during any update event on this instance. In case you intend to reset this later on, simply obtain a new instance from the entity manager. -
setCreated
- Specified by:
setCreated
in interfaceTimestamped
-
getCreated
- Specified by:
getCreated
in interfaceTimestamped
-
setLastModified
- Specified by:
setLastModified
in interfaceTimestamped
-
getLastModified
- Specified by:
getLastModified
in interfaceTimestamped
-