Added onPrePersist and onPreUpdate methods