title: JPA EventListener method not called on change to many-to-many collection?
body: <p>I am using JPA with Hibernate as the implementation in my Spring webapp.</p>
  
  <p>I use <code>EntityListener</code>s for auditing (Spring-data) and other notification purposes. In general it works fine. However, <strong>when changes are made to a many-to-many collection/relationship, without any other change to any field of the entities themselves</strong>, the <code>@PostUpdate</code> event of the <code>EventListener</code>s are not fired.</p>
  
  <p>To give a concrete example : I have a <code>User</code> and a <code>Role</code> entities, with a many-to-many relationship between them, using an underlying table. If I go to my user management GUI, and add (or remove) roles to a user, without changing anything else, the "postUpdate" event is not triggered, the auditing information is not modified.</p>
  
  <p>There is some logic to it (at a low level) since neither the user or the role tables are updated, only the relationship table is. However the relationship itself is not modeled as an entity class and so it is impossible to apply auditing to it, at least not at the JPA level, so it would make sense to trigger the change event for the entity itself.</p>
  
  <p>Is this a normal JPA behaviour, or is this specific to Hibernate ? Are there any workaround ? What would you do to trigger this event ? Thoughts ?</p>
  
  <p>Note : I found very few mentions of this limitation, and even less solutions :
  <a href="https://stackoverflow.com/questions/9502168/firing-jpa-listeners-on-collection-field-change">This SO question</a> (without useful answer) and <a href="https://forum.hibernate.org/viewtopic.php?p=2426092" rel="noreferrer">this post on Hibernate's forum</a> also without any answer.</p>