它在数据库中存储一个整数而不是我请求的字符串。
这是包含枚举的类。
@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 :(得分:1)
一个可能的原因是您的@Enumerated
注释没有生效,因为BaseModel
中的注释放在属性而不是字段上。在字段或属性上放置注释应该在继承层次结构中保持一致。