Last active
March 8, 2016 18:16
-
-
Save dilnei/a02a55eab71f01dbdfac to your computer and use it in GitHub Desktop.
listeners do Hibernate
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
/** | |
* The datetime that this record is created. | |
*/ | |
@NotNull | |
@Temporal(TemporalType.TIMESTAMP) | |
private Date creationDate; | |
/** | |
* The datetime that this record is modified. | |
*/ | |
@NotNull | |
@Temporal(TemporalType.TIMESTAMP) | |
private Date lastModificationDate; | |
@PrePersist | |
public void whenInsert() { | |
creationDate = new Date(); | |
lastModificationDate = new Date(); | |
} | |
@PreUpdate | |
public void whenUpdate() { | |
lastModificationDate = new Date(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment