我有一个包含@Embeddable @ElementCollection的en Entity。当我试图保持这一点时,我总是得到一个NonUniqueObjectException。
@Entity
@Audited
public class Entity(){
private Long entityId;
@ElementCollection
private Set<MyEmbeddableCollection> collections = new HashSet<MyEmbeddableCollection>();
}
@Embeddable
public class myEmbeddableCollection(){
private String myId;查看日志,我可以看到Envers没有包含envers表的myId。仅包含对实体的引用。
[HIST_Entity_collections#{revision_id=DefaultRevisionEntity(id = 3, revisionDate = 2013-sep-04 08:44:56), revisionTyp=ADD, entityId=1}]我使用的是hibernate-envers 4.2.0,hibernate redhat-1。有没有人对为什么会发生这种情况有任何解决方案或解释?
发布于 2013-09-04 16:28:05
Hibernate中有一个bug,请参阅here,这看起来是您的问题所在。
以下是一种解决方法:
public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy {
@Override
public String propertyToColumnName(String propertyName) {
return super.propertyToColumnName(propertyName.replace(".collection&&element.", "."));
}
}https://stackoverflow.com/questions/18607422
复制相似问题