How to over ride audit field having @CreatedDate
. if value is not set for audit field @CreatedDate
should be applied other wise it should take the value that has been set. Is there any feature to enable in spring JPA.
It's not elegant, but if you want to reset the value of the @CreatedDate
field, you can save the entity after the initial save with any date you like:
// creates entity
repository.save(entity);
// overwrite created date on the entity
entity.setCreatedDate(getSomeCreatedDate());
// re-save the entity
repository.save(entity);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With