Firing JPA listeners on collection field change

落花浮王杯 提交于 2019-12-10 07:38:31

问题


I am using EntityListeners (@PreUpdate) to perform certain actions once my entities change. However I noticed that changes of a collection inside an entity does not fire the JPA entity listener, that makes sense because the table containing the entity was not changed, but a many to many table was.

Is there a way to make the entity listener fire in case of a collection change?


回答1:


Listeners are fired for versioned entities (see javax.persistence.Version). Found via this answer: https://stackoverflow.com/a/17073342/12039




回答2:


I would expect the events to be called. What JPA provider are you using?



来源:https://stackoverflow.com/questions/9502168/firing-jpa-listeners-on-collection-field-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!