title: Integrity constraint violated when creating custom revision entity with hibernate envers
body: <p>I have an application that uses hibernate envers and has auditing for some of the entities.</p>
  
  <p>I want to add some extra columns in the audit tables and followed the standard instructions that I have found in multiple blogs.</p>
  
  <p>First I created the a custom revision entity: </p>
  
  <pre><code>@Entity
  @RevisionEntity(UserRevisionListener.class)
  public class UserRevEntity extends DefaultRevisionEntity {
      private String username;
  
      public String getUsername() { return username; }
  
      public void setUsername(String username) { this.username = username; }
  }
  </code></pre>
  
  <p>then the revision listener:</p>
  
  <pre><code>public class UserRevisionListener implements RevisionListener {
      @Override
      public void newRevision(Object revisionEntity) {
          UserRevEntity exampleRevEntity = (UserRevEntity) revisionEntity;
          exampleRevEntity.setUsername("TEST");
      }
  }
  </code></pre>
  
  <p>The problem is that when the application saves an entity (let's call it MyEntity) it violates a foreign key constraint on the database.</p>
  
  <p>What I concluded is that up until now envers wrote into the REVINFO table but now by looking at the query that JPA sends to the db I see that it writes to the USERREVTABLE. Because the table that MyEntity is persisted has a foreign key constraint referencing REVINFO it causes the constraint violation.</p>
  
  <p>How can I overcome this issue? Is there any envers annotation to fix this scenario?</p>
  
  <p>Please help, thanks in advance.</p>