2011-02-03 2 views
0

요청한 문자열이 아닌 데이터베이스에 정수를 저장합니다.이 JPA 열거 형이 작동하지 않는 이유는 무엇입니까?

다음은 열거 형을 포함하는 클래스입니다. 나는이 일을해야 알

public enum DocumentType { 
    policy,procedure,webbookmark,newsrelease,collectionLetter,whitepaper,busform, 
    newsarticle ; 
} 

: 여기

@Entity 
@Inheritance(strategy=InheritanceType.JOINED) 
public abstract class Document extends BaseModel { 

    private String title = new String(); 
    private String description = new String(); 

    **@Enumerated(EnumType.STRING) 
    private DocumentType documentType;** 

    @Embedded 
    private DocumentImage documentImage; 
    // if document should be displayed or published on the web site. 
    private Boolean published = new Boolean(false); 

    public Document(DocumentType docType) { 
     super(); 
     documentType = docType; 
     setDocumentImage(new DocumentImage()); 

    } 

} 

는 열거 클래스입니다. 어떤 아이디어?

+0

당신이 말한대로, 잘 작동해야합니다. 다른 JPA 제공 업체 (예 : DataNucleus)에서도 정상적으로 작동합니다. – DataNucleus

+1

괜찮아 보입니다. - Dialect가 올바르게 구성되어 있고 올바른 패키지의 열거 형 주석입니까? – Ralph

답변

1

가능한 이유 중 하나는 BaseModel의 특수 효과가 필드가 아닌 속성에 배치되므로 사용자의 @Enumerated 특수 효과가 적용되지 않는 것입니다. 필드 또는 속성에 대한 주석 배치는 상속 계층 구조 전반에 걸쳐 일관성을 유지해야합니다.

관련 문제