【发布时间】:2012-11-10 01:39:37
【问题描述】:
我正在尝试使用休眠将一组枚举存储到数据库中。
枚举类似于
public enum SomeEnum {
ITEM,
ITEM2,
}
我有一个像这样的 Hibernate 模型实体
@Entity
public class TableObject implements BaseObject {
private Long id;
private Set<SomeEnum> someEnumSet;
@Column(name = "TABLE_COLUMN", nullable = true, insertable = true, updatable = true)
@ElementCollection
public Set<SomeEnum> getSectionSet() {
return sectionSet;
}
public void setSectionSet(Set<SomeEnum> sectionSet) {
this.sectionSet = sectionSet;
}
}
而且我不认为@ElementCollection 注释是正确的。 'TABLE_COLUMN' 列在 DB 中属于 CLOB 类型。 (甲骨文)。
谢谢, 亚历克斯。
【问题讨论】:
标签: java spring hibernate enums