2011-09-09 5 views
4

에 포함 된 유형을 반복하는 방법 내가 최대 절전 모드 3.6.x에서최대 절전 모드

@Entity @Table(name = "address") @Inheritance() 
public abstract class Address { 
    @Column(name = "address_type") @Enumerated(EnumType.STRING) 
    private final AddressType addressType; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line1"))}) 
    private final AddressLine addressLine1; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line2"))}) 
    private final AddressLine addressLine2; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line3"))}) 
    private final AddressLine addressLine3; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line4"))}) 
    private final AddressLine addressLine4; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line5"))}) 
    private final AddressLine addressLine5; 

    @Embedded @AttributeOverrides({@AttributeOverride(name = "postcode", column = @Column(name = "postcode"))}) 
    private final Postcode postcode; 
} 

나는이 오류를 받고 있어요에 매핑하기 위해 노력하고있어이 클래스가 있습니다. (내가 완전히 이해하지 않는 - 사람은 그것을 설명 할 수 있습니까?)

엔티티 매핑

반복 열 : 주소 열 : addressLine이 ( 삽입으로 매핑해야 = "false"를 업데이 트 = "false"를)

@Embeddable AddressLine은 문자열을 래핑하는 객체 일 뿐이지 만 이후에 동작/규칙을 추가 할 수 있도록 유형을 유지하고자합니다.

Any는 이러한 유형의 구성을 허용한다고 제안합니까?

답변

1

나는이 질문에서 얻은 오류가 사본 & 붙여 넣기 범죄로 인한 것이라고 부끄럽다.

질문 코드에는 없지만 실제 코드베이스에는 중복 된 AddressLines 1,2,3 및 4 내의 @Column 주석 이름 값이 고유하게 변경되지 않았습니다.

예를 들어 -이 모든 열 이름은 예상대로이 예제가 작동 고유 경우 모두 @Column 이름 값이

@Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line1"))}) 
private final AddressLine addressLine1; 

@Embedded @AttributeOverrides({@AttributeOverride(name = "addressLine", column = @Column(name = "address_line1"))}) 
private final AddressLine addressLine2; 

"address_line1"의 동일로 BAD입니다.

1

@AttributeOverride를 사용하지 않았지만이 오류 메시지를 알고 있습니다. 같은 이름을 가진 컬럼의 다중 매핑 때문에 야기된다.이 경우 Hibernate는 컬럼 재정의 정의를 무시했다.

그러나 제 경우에는 @ManyToOne 클래스를 사용했기 때문에 솔루션은 원래 열 이름을 무시하는 @JoinColumns 정의였습니다.