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:
  • 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

      public void setCreated(Instant created)
      Specified by:
      setCreated in interface Timestamped
    • getCreated

      public Instant getCreated()
      Specified by:
      getCreated in interface Timestamped
    • setLastModified

      public void setLastModified(Instant lastModified)
      Specified by:
      setLastModified in interface Timestamped
    • getLastModified

      public Instant getLastModified()
      Specified by:
      getLastModified in interface Timestamped