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
ConstructorsModifierConstructorDescriptionprotectedCreates a newAbstractTimestampedJpaEntitywith null ID and with the created and updated timestamps also set to null.protectedCreates a newAbstractTimestampedJpaEntitywith the given ID and with the created and updated timestamps set to the current time.protectedTimestampedJpaEntity(ID id, ZonedDateTime created, ZonedDateTime updated) Creates a newAbstractTimestampedJpaEntitywith the given ID and timestamps. -
Method Summary
Modifier and TypeMethodDescriptioncreated()Gives the time and date that the entity was created.voidsetUpdated(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 newAbstractTimestampedJpaEntitywith 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 newAbstractTimestampedJpaEntitywith 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 newAbstractTimestampedJpaEntitywith 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- ifcreatedorupdatedisnull
-
-
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- ifupdatedisnull
-