Package org.omnifaces.persistence.model
Class TimestampedEntity<I extends Comparable<I> & Serializable>
java.lang.Object
org.omnifaces.persistence.model.BaseEntity<I>
org.omnifaces.persistence.model.GeneratedIdEntity<I>
org.omnifaces.persistence.model.TimestampedEntity<I>
- Type Parameters:
I
- The generic ID type.
- All Implemented Interfaces:
Serializable
,Comparable<BaseEntity<I>>
,Identifiable<I>
,Timestamped
- Direct Known Subclasses:
VersionedEntity
@MappedSuperclass
public abstract class TimestampedEntity<I extends Comparable<I> & Serializable>
extends GeneratedIdEntity<I>
implements Timestamped
Mapped superclass for timestamped entity.
It extends from GeneratedIdEntity
which in turn extends from BaseEntity
.
In addition to the "id" column, it specifies two timestamp columns, named "created" and "lastModified".
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.GeneratedIdEntity
getId, setId
-
Constructor Details
-
TimestampedEntity
public TimestampedEntity()
-
-
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
-