com.agileactors.crud.domain.AbstractUpdatable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agile-actors-spring-boot-crud-api Show documentation
Show all versions of agile-actors-spring-boot-crud-api Show documentation
This is a library that extends Spring Boot functionality and offers a convenient and easy way to expose a domain's CRUD (Create, Read, Update, Delete) operations.
The newest version!
package com.agileactors.crud.domain;
import java.io.Serializable;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.PreUpdate;
import lombok.Getter;
import lombok.Setter;
/**
* Abstract base class for updatable entities. Introduces an updatedAt which is always updated upon
* enity storage
*
* @author Alexis Panousis
* @param the type of the auditing type's identifier.
*/
@MappedSuperclass
@Getter
@Setter
public abstract class AbstractUpdatable extends AbstractPersistable {
@Column(name = "updated_at")
protected LocalDateTime updatedAt;
public void onPrePersist() {
super.onPrePersist();
updatedAt = createdAt;
}
@PreUpdate
public void onPreUpdate() {
//TODO: Inject clock instance
updatedAt = LocalDateTime.now();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy