Home > Back-end >  @ Prepersist annotation method when performing?
@ Prepersist annotation method when performing?

Time:03-06

In a recent study using ReactiveCrudRepository, I use of database is directing,
In order to record the time class is created, in adding the private domain classes Date createdAt fields, and add the method in the domain classes:
 @ PrePersist 
Public void createdAt () {
Enclosing createdAt=new Date ();
}
see online, @ Prepersist annotation methods seem to be in the Repository. The save () method is called before execution,
My class in the field of the Controller class using a no-parameter constructor generated in the field of class object, and then use the ReactiveCrudRepository save method to save domain object to a database, but I found that saved to the document in the database no time fields,
Is there a way to make application for domain classes automatically set the time?
  • Related