Lukasz Antoniak commented on Bug HHH-8171

Good point!

The exception affecting current Envers version:

Caused by: javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [EmbSetEnt_set_AUD#{REV=SequenceIdRevisionEntity(id = 4, revisionDate = 2013-04-11 14:28:38), REVTYPE=ADD, EmbeddableSetEntity_id=2}]
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1533)
	at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1486)
	at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:82)
	... 40 more

IMO more elegant solution would be to add all component fields to composite-id tag (compare mapping generated for @ElementCollection of primitive types), but it is not possible due to implicit NOT NULL constraint in primary keys columns.

Kristoffer Lundberg, your solution looks good! Can you submit two pull requests - one targeting branch 4.2 and another one for master? Just please document new configuration options in documentation/src/main/docbook/devguide/en-US/Envers.xml, use proper Hibernate formatting (https://community.jboss.org/wiki/ContributingToHibernateUsingEclipse or https://community.jboss.org/wiki/ContributingToHibernateUsingIntelliJ), and test by adding two elements to new EmbeddableSetEntity instance in revision 5.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira