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