Reputation: 451
I use this piece of line to merge:
partner = em.merge(partner);
and this is in my entity:
@PrePersist
public void updateModificationDate(){
this.lastModificationDate = new Date();
}
So as you can see, I want to keep up when the entity was last changed,
but the method never gets called,
Anybody an idea of what I could do?
Upvotes: 0
Views: 3980
Reputation: 614
Try forcing em.flush() but I'm not very sure whether forcing a flush is a good practice.
Upvotes: 0
Reputation: 118
You can add to your entity the following annotation:
@EntityListeners(SaveOrUpdateDateListener.class)
And actually listener would be:
public class SaveOrUpdateDateListener {
@PrePersist
@PreUpdate
public void setDate(final CertApplication entity) {
final Date now = new Date();
entity.setUpdated(now);
}
}
Upvotes: 3