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 ;
}
我知道這應該工作。有任何想法嗎?
正如你所說,應該工作得很好。適用於其他JPA提供商(例如DataNucleus) – DataNucleus 2011-02-03 07:51:42