开发者

JPA Adding Logic to Removing an Entity

开发者 https://www.devze.com 2023-01-13 12:10 出处:网络
I am somewhat new to using JPA -- I\'ll put that out there ri开发者_如何学运维ght off the bat. I\'m getting more familiar with it, but there are big holes in my knowledge right now.

I am somewhat new to using JPA -- I'll put that out there ri开发者_如何学运维ght 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.


Entity class may have methods annotated with @PreRemove or @PostRemove.


If you are using Eclipselink, it has a much more fine grained native event system via the DescriptorEventListener interface.

0

精彩评论

暂无评论...
验证码 换一张
取 消