JPA and J2EE links
- JPA home
- Java EE Tutorial
- JPA & Spring Tutorial
- JPA Article
- Testing JPA outside container
- J2EE Articles
- Annotation Reference
- JPA Query Language Reference
I was looking for a way to automatically set create date on insert and modified date on update via JPA. The @PrePersist and @PreUpdate work like a charm:
/**
* Auto set create/modify date on insert
*/
@PrePersist
private void onInsert()
{
setCreateDate(new Date());
setModifyDate(new Date());
}
/**
* Auto set modify date on update
*/
@PreUpdate
private void onUpdate()
{
setModifyDate(new Date());
}
Hibernate
Add new attachment
Only authorized users are allowed to upload new attachments.