2011-02-03 7 views
0

私は要求したとおりに文字列ではなくデータベースに整数を格納しています。このJPA列挙型はなぜ機能しないのですか?

ここに列挙型を含むクラスです。

@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()); 

    } 

} 

、ここで列挙クラスです:

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

私は、これは動作するはずです知っています。何か案は?

+0

あなたが言うように、うまく動作するはずです。他のJPAプロバイダ(例:DataNucleus)でも正常に動作します – DataNucleus

+1

正常です。 - あなたのDialectは正しく構成されていますか、それは正しいパッケージの列挙型アノテーションですか? – Ralph

答えて

1

BaseModelの注釈がフィールドではなくプロパティに配置されるため、@Enumeratedアノテーションが有効になる可能性があります。フィールドまたはプロパティに対するアノテーションの配置は、継承階層全体で一貫している必要があります。

関連する問題