Created
February 13, 2016 19:50
-
-
Save lindabjalla/88fd502bbd3792b69b0b to your computer and use it in GitHub Desktop.
AbstractEntity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package se.grouprich.projectmanagement.model; | |
import java.util.Date; | |
import javax.persistence.Column; | |
import javax.persistence.EntityListeners; | |
import javax.persistence.GeneratedValue; | |
import javax.persistence.Id; | |
import javax.persistence.MappedSuperclass; | |
import org.springframework.data.annotation.CreatedBy; | |
import org.springframework.data.annotation.CreatedDate; | |
import org.springframework.data.annotation.LastModifiedBy; | |
import org.springframework.data.annotation.LastModifiedDate; | |
import org.springframework.data.jpa.domain.support.AuditingEntityListener; | |
@MappedSuperclass | |
@EntityListeners(AuditingEntityListener.class) | |
public abstract class AbstractEntity | |
{ | |
@Id | |
@GeneratedValue | |
Long id; | |
@Column(nullable = false, unique = true) | |
Long controlNumber; | |
@Column(name = "createdBy") | |
@CreatedBy | |
private String createdBy; | |
@Column | |
@CreatedDate | |
private Date createdDate; | |
@Column | |
@LastModifiedBy | |
private String lastModifiedBy; | |
@Column | |
@LastModifiedDate | |
private Date lastModifiedDate; | |
protected AbstractEntity() | |
{ | |
setControlNumber(); | |
} | |
public Long getId() | |
{ | |
return id; | |
} | |
public Long getControlNumber() | |
{ | |
return controlNumber; | |
} | |
public void setControlNumber() | |
{ | |
Date now = new Date(); | |
Long time = now.getTime(); | |
controlNumber = time; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment