I have en Entity
containing an @Embeddable @ElementCollection
. When trying to persist this I keep getting a NonUniqueObjectException
.
@Entity
@Audited
public class Entity(){
private Long entityId;
@ElementCollection
private Set<MyEmbeddableCollection> collections = new HashSet<MyEmbeddableCollection>();
}
@Embeddable
public class myEmbeddableCollection(){
private String myId;
Looking at the log I can see that Envers doesn't include the myId
to the envers table. Only the reference to the entity is included.
[HIST_Entity_collections#{revision_id=DefaultRevisionEntity(id = 3, revisionDate = 2013-sep-04 08:44:56), revisionTyp=ADD, entityId=1}]
I am using hibernate-envers 4.2.0.Final-redhat-1. Does anybody have any solution or explanation to why this is happening?
There is a bug in Hibernate, see here, that looks like your problem.
Here is a workaround: