Reputation: 4190
I am somewhat new to using JPA -- I'll put that out there right off the bat. I'm getting more familiar with it, but there are big holes in my knowledge right now.
I am working on an application that uses JPA, and deletes entities using the EntityManager.remove(Object entity) function. However, the application also links into a third-party application, and I would like to add logic that gets executed whenever a certain type of Entity is removed from the persistence layer.
My question is this. Is there a way to add logic to the EntityManager.remove(Object entity) function on a Entity class level, such that every time that type of entity is deleted the extra logic is executed?
Thanks much.
Upvotes: 0
Views: 453
Reputation: 1
If you are using Eclipselink, it has a much more fine grained native event system via the DescriptorEventListener interface.
Upvotes: 0
Reputation: 242786
Entity class may have methods annotated with @PreRemove
or @PostRemove
.
Upvotes: 3