2013-09-04 4 views
2

나는 에 @Embeddable @ElementCollection이 포함되어 있습니다. 이것을 유지하려고 할 때 나는 계속 NonUniqueObjectException을 얻는다.감사 @Embeddable @ElementCollection with Hibernate-envers

@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}] 

최대 절전 모드 4.2.0.Final-redhat-1을 사용하고 있습니다. 왜 이런 일이 발생했는지에 대한 해결책이나 설명이 있습니까?

답변

1

Hibernate에 문제가있는 버그가 있습니다 (here 참조). 당신은`당신의 영속에`넣어해야합니다

public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy { 
    @Override 
    public String propertyToColumnName(String propertyName) { 
     return super.propertyToColumnName(propertyName.replace(".collection&&element.", ".")); 
    } 
} 
+0

: 여기

는 해결 방법입니다. XML 파일. – Kevin