Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @MappedSuperclass
- public abstract class TimestampedEntity {
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "created", nullable = false)
- private Date created;
- @Temporal(TemporalType.TIMESTAMP)
- @Column(name = "updated", nullable = false)
- private Date updated;
- @PrePersist
- protected void onCreate() {
- updated = created = new Date();
- }
- @PreUpdate
- protected void onUpdate() {
- updated = new Date();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement