model.domain.object.AbstractDomainObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of abstract-domain Show documentation
Show all versions of abstract-domain Show documentation
A bunch of classes that help developers building their domain object classes.
package model.domain.object;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import model.domain.util.date.DateGenerator;
/**
* {@link AbstractDomainObject} is an abstract implementation of
* {@link DomainObject}.
*
* @see DomainObject
*
* @author Jhonathan Camacho
* @author Jhonys Camacho
*
*/
@MappedSuperclass
public abstract class AbstractDomainObject implements DomainObject {
/**
* Generated serial version id created at 21 April 2017.
*/
private static final long serialVersionUID = -2863804897094916874L;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_at")
private Date createdAt;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_at")
private Date updatedAt;
public AbstractDomainObject() {
}
@PrePersist
public void createAt() {
this.createdAt = DateGenerator.toInstant();
}
@PreUpdate
public void updatedAt() {
this.updatedAt = DateGenerator.toInstant();
}
public abstract long getId();
public Date getCreatedAt() {
return this.createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return this.updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
}