简体   繁体   中英

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?

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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM