问题
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