【发布时间】:2011-02-03 01:17:26
【问题描述】:
它在数据库中存储一个整数,而不是我要求的字符串。
这是包含枚举的类。
@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)
-
看起来不错。 - 你的方言配置是否正确,是否是正确包中的枚举注释?