Implement LastModified event listener on prePersist and preUpdate events

It fixes the #384 issue.