小编Ale*_*hiv的帖子

hibernate将Set <Enum>存储到数据库中

我正在尝试使用hibernate将一组枚举存储到数据库中.

枚举就像是

public enum SomeEnum { 
    ITEM,
    ITEM2,
}
Run Code Online (Sandbox Code Playgroud)

我有一个像这样的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;
}
}
Run Code Online (Sandbox Code Playgroud)

我不认为@ElementCollection注释是正确的.'TABLE_COLUMN'列在DB中的类型为CLOB.(甲骨文).

谢谢,亚历克斯.

java enums spring hibernate

8
推荐指数
1
解决办法
7347
查看次数

标签 统计

enums ×1

hibernate ×1

java ×1

spring ×1