首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用hibernate-envers审核@Embeddable @ElementCollection

使用hibernate-envers审核@Embeddable @ElementCollection
EN

Stack Overflow用户
提问于 2013-09-04 15:04:30
回答 1查看 1.9K关注 0票数 2

我有一个包含@Embeddable @ElementCollection的en Entity。当我试图保持这一点时,我总是得到一个NonUniqueObjectException

代码语言:javascript
复制
@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。仅包含对实体的引用。

代码语言:javascript
复制
[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。有没有人对为什么会发生这种情况有任何解决方案或解释?

EN

回答 1

Stack Overflow用户

发布于 2013-09-04 16:28:05

Hibernate中有一个bug,请参阅here,这看起来是您的问题所在。

以下是一种解决方法:

代码语言:javascript
复制
public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy {
    @Override
    public String propertyToColumnName(String propertyName) {
        return super.propertyToColumnName(propertyName.replace(".collection&&element.", "."));
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18607422

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档