All Downloads are FREE. Search and download functionalities are using the official Maven repository.

model.domain.object.AbstractDomainObject Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy