开发者

JPA Adding Logic to Removing an Entity

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜