Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Spring-data MongoDB @prepersist @preupdate without using JPA

I want to learn, is it possible to use @prepersist/@preupdate like annotations in spring-data-mongodb documents i mean is it possible to make modifications before save or before update? I look forward documentation of spring data mongodb There is a listener BeforeConvertListener, but i want to use without listener, inside @document object just put an annotation to attributes. Is it possible?

like image 641
erhanasikoglu Avatar asked Jan 21 '14 09:01

erhanasikoglu


1 Answers

I found a solution, but just related with my problem. My problem was i need to prepresist or preupdate modificationDates, insertDates. So spring-data can provide annotations for them :

@CreatedDate -> insertDate ( prepersist )
@LastModifiedDate -> updateDate ( preupdate )
like image 171
erhanasikoglu Avatar answered Sep 30 '22 17:09

erhanasikoglu