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". TheId
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, unlessskipAdjustLastModified()
is called beforehand.- Author:
- Bauke Scholtz
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.omnifaces.persistence.model.Identifiable
ID
-
-
Constructor Summary
Constructors Constructor Description TimestampedBaseEntity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Instant
getCreated()
Instant
getLastModified()
void
onPrePersist()
void
onPreUpdate()
void
setCreated(Instant created)
void
setLastModified(Instant lastModified)
void
skipAdjustLastModified()
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, equals, hashCode, 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
-
-
-
-
Method Detail
-
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
public void setCreated(Instant created)
- Specified by:
setCreated
in interfaceTimestamped
-
getCreated
public Instant getCreated()
- Specified by:
getCreated
in interfaceTimestamped
-
setLastModified
public void setLastModified(Instant lastModified)
- Specified by:
setLastModified
in interfaceTimestamped
-
getLastModified
public Instant getLastModified()
- Specified by:
getLastModified
in interfaceTimestamped
-
-