java hibernate envers set other primary key for audit table
<p>I want to map a Map in JPA Hibernate. The set up looks like</p>

<pre><code>@Entity(name = "reservation")
@Table(name = "reservation")
@Access(AccessType.FIELD)
@Audited
public class ReservationEntity {

  // other fields

  @ElementCollection(fetch = FetchType.EAGER)
  @MapKeyColumn(name = "discountType")
  @Column(name = "discountAmount")
  @CollectionTable(
          name="discountTypeAndAmount",
          joinColumns=@JoinColumn(name="reservation_id")
  )
  private Map&lt;DiscountType, BigDecimal&gt; discountTypeAndAmount;

}
</code></pre>

<p>I can write the entity to the database the first time, but when I update the entity, I get the following error upon <code>entitymanager.getTransaction().commit()</code>:</p>

<pre><code>Caused by: javax.persistence.EntityExistsException: A different object with
the same identifier value was already associated with the session : 
[discountTypeAndAmount_AUD#{REV=DefaultRevisionEntity(id = 3, 
revisionDate = Dec 20, 2016 8:52:45 PM), element=10.00,  
ReservationEntity_reservation_id=1, mapkey=CASE_STUDY}]
</code></pre>

<p>In the exception, <code>CASE_STUDY</code> is one of the enums. <code>discountTypeAndAmount_AUD</code> is the audit log table auto generated. </p>

<p>It looks like the audit table <code>discountTypeAndAmount</code> was generated with a composite key made up of <code>REV</code> (revision id), <code>reservation_id</code>, <code>discountType</code>, and <code>discountAmount</code> and the error is thrown because envers doesn't know how to handle <code>BigDecimal</code> as part of a primary key. </p>

<p>Is there an annotation to set the primary key for the audit table to be a composite of just <code>REV</code> (revision id), <code>reservation_id</code>, and <code>discountType</code>? Since the field is a map anyway, there is really no need to have <code>discountAmount</code> as part of the primary key.</p>