Advertisement
Guest User

Untitled

a guest
Jul 25th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. @MappedSuperclass
  2. public abstract class TimestampedEntity {
  3.  
  4. @Temporal(TemporalType.TIMESTAMP)
  5. @Column(name = "created", nullable = false)
  6. private Date created;
  7.  
  8. @Temporal(TemporalType.TIMESTAMP)
  9. @Column(name = "updated", nullable = false)
  10. private Date updated;
  11.  
  12. @PrePersist
  13. protected void onCreate() {
  14. updated = created = new Date();
  15. }
  16.  
  17. @PreUpdate
  18. protected void onUpdate() {
  19. updated = new Date();
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement