Java 使用hibernate envers审核@Embeddeble@ElementCollection

Java 使用hibernate envers审核@Embeddeble@ElementCollection,java,hibernate,hibernate-envers,embeddable,Java,Hibernate,Hibernate Envers,Embeddable,我有一个包含@embeddeble@ElementCollection的en实体。当试图持久化这个时,我不断得到一个ununiqueobjectexception @Entity @Audited public class Entity(){ private Long entityId; @ElementCollection private Set<MyEmbeddableCollection> collections = new HashSet<M

我有一个包含
@embeddeble@ElementCollection
的en
实体。当试图持久化这个时,我不断得到一个
ununiqueobjectexception

@Entity
@Audited
public class Entity(){

    private Long entityId;

    @ElementCollection
    private Set<MyEmbeddableCollection> collections = new HashSet<MyEmbeddableCollection>();

}

@Embeddable
public class myEmbeddableCollection(){
    private String myId;
我使用的是HibernateEnvers4.2.0.Final-redhat-1。
有人对为什么会发生这种情况有任何解决方案或解释吗?

Hibernate中有一个bug,请看,这看起来像是您的问题

以下是一个解决方法:

public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy {
    @Override
    public String propertyToColumnName(String propertyName) {
        return super.propertyToColumnName(propertyName.replace(".collection&&element.", "."));
    }
}
您需要将
放入persistence.xml文件中。
public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy {
    @Override
    public String propertyToColumnName(String propertyName) {
        return super.propertyToColumnName(propertyName.replace(".collection&&element.", "."));
    }
}