title: NullPointerException at org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(...)
body: <p>I'm using Envers to audit different fields of my entities. The framework works in general but it seems to have problems with some kinds of entity mapping. All former problems I could solve myself... but this time I'm stuck.</p>
  
  <p>When inserting some entity into the database I get the following exception:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at org.hibernate.envers.event.AuditEventListener.generateBidirectionalCollectionChangeWorkUnits(AuditEventListener.java:108)
  </code></pre>
  
  <p>I'm not completly sure which entity causes this because it is fired during flush() and the complex application inserts many different entities within one larger transaction.</p>
  
  <p>We are using some HibernateEventListener that fires right before that exception... so I suppose that entity is the cause. The persistence.xml is configured this way:</p>
  
  <pre><code>        &lt;property name="hibernate.ejb.event.post-insert" value="com.xyz.hibernate.events.listeners.MyListener,org.hibernate.envers.event.AuditEventListener" /&gt;
  </code></pre>
  
  <p>If this is true than the entity is the following (excerpt):</p>
  
  <pre><code>@Entity
  @Table(name = Property.TABLE_NAME, uniqueConstraints = @UniqueConstraint(columnNames = { "ENTITY_ID", "DESCRIPTOR_ID", "PROMOLEVEL_ID" }))
  public class Property extends AbstractEntity {
  private static final long serialVersionUID = 1L;
  
  public static final String TABLE_NAME = "E_BUSINESS_PROPERTIES";
  public static final String PROPERTY_ENTITY = "entity";
  public static final String PROPERTY_DESCRIPTOR = "descriptor";
  public static final String PROPERTY_PROMOLEVEL = "promolevel";
  
  @Audited
  @ManyToOne(optional = false)
  private ProjectPropertyDescriptor descriptor;
  
  @Audited
  @ManyToOne
  private ExtendedEntity entity;
  
  @Audited
  @ManyToOne
  private AbstractPromotionLevel promolevel;
  
  @Audited
  @OneToMany(cascade = { CascadeType.ALL }, mappedBy = PropertyValue.PROPERTY_PROPERTY)
  private List&lt;PropertyValue&gt; propertyValues = new ArrayList&lt;PropertyValue&gt;();
  
  // some accessors stripped!
  
  } 
  </code></pre>
  
  <p>Does anyone have an idea where to look for? As soon as we disable Envers everything works fine. But we need envers to generate a history of changes.</p>