I would like to execute certain method every time a specific Entity is persisted. This method should perform some kind of checking on entity object, so its need a access to this specific object.
Is there an Annotation, or other method allowing me to do so? Basically, it should be working like some kind of trigger.
CodePudding user response:
I think you are looking for this
https://www.baeldung.com/jpa-entity-lifecycle-events
So you can use @PostPersist
inside your entity
CodePudding user response:
You could consider using entity validation annotations directly on your entity objects, e.g. hibernate entity annotations. If you register your entity validator, these can be called automatically prior to entity save.
CodePudding user response:
does after
point cut of spring aop can solve your problem?