Class TimestampedJpaEntity<ID>
java.lang.Object
com.reallifedeveloper.common.infrastructure.persistence.BaseJpaEntity<ID>
com.reallifedeveloper.common.infrastructure.persistence.TimestampedJpaEntity<ID>
- Type Parameters:
ID
- the type of the primary key
A base class for JPA entities that need to keep track of when they where created and when they were last updated.
- Author:
- RealLifeDeveloper
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a newAbstractTimestampedJpaEntity
with null ID and with the created and updated timestamps also set to null.protected
Creates a newAbstractTimestampedJpaEntity
with the given ID and with the created and updated timestamps set to the current time.protected
TimestampedJpaEntity
(ID id, ZonedDateTime created, ZonedDateTime updated) Creates a newAbstractTimestampedJpaEntity
with the given ID and timestamps. -
Method Summary
Modifier and TypeMethodDescriptioncreated()
Gives the time and date that the entity was created.void
setUpdated
(ZonedDateTime updated) Sets the time and date that the entity was last updated.updated()
Gives the time and date that the entity was last updated.Methods inherited from class com.reallifedeveloper.common.infrastructure.persistence.BaseJpaEntity
finalize, id
-
Constructor Details
-
TimestampedJpaEntity
protected TimestampedJpaEntity()Creates a newAbstractTimestampedJpaEntity
with null ID and with the created and updated timestamps also set to null.This constructor should normally only be used by Hibernate, and you are encouraged to create a no-argument package private constructor in your entities that call this.
-
TimestampedJpaEntity
Creates a newAbstractTimestampedJpaEntity
with the given ID and with the created and updated timestamps set to the current time.- Parameters:
id
- the ID of the new entity
-
TimestampedJpaEntity
Creates a newAbstractTimestampedJpaEntity
with the given ID and timestamps.- Parameters:
id
- the ID of the new entitycreated
- the time and date the entity was createdupdated
- the time and date the entity was last updated- Throws:
IllegalArgumentException
- ifcreated
orupdate
isnull
-
-
Method Details
-
created
Gives the time and date that the entity was created.- Returns:
- the timestamp of creation
-
updated
Gives the time and date that the entity was last updated.- Returns:
- the timestamp of last update
-
setUpdated
Sets the time and date that the entity was last updated.- Parameters:
updated
- the timestamp of last update- Throws:
IllegalArgumentException
- ifupdated
isnull
-