触发JPA侦听器进行收集字段更改 [英] Firing JPA listeners on collection field change

查看:170
本文介绍了触发JPA侦听器进行收集字段更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我的实体发生更改,我正在使用EntityListeners(@PreUpdate)执行某些操作. 但是我注意到,实体内部集合的更改不会触发JPA实体侦听器,这是有道理的,因为包含该实体的表并未更改,而多对多表已更改.

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?

推荐答案

针对版本化的实体触发了侦听器(请参见 https://stackoverflow.com/a/17073342/12039

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

这篇关于触发JPA侦听器进行收集字段更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆