0
我想在我的spring应用程序中使用枚举的弹簧数据集,这些数据集将存储在db中。目前我以这种方式尝试过:枚举Spring数据集
@NotNull
@Column(name = "ROLES")
@Enumerated(EnumType.STRING)
@ElementCollection(targetClass = Role.class)
private Role role;
@NotNull
@Column(name = "PERMISSIONS")
@Enumerated(EnumType.STRING)
@ElementCollection(targetClass = Permission.class)
private Set<Permission> permissions;
但是正如你所知道的那样它不起作用。我怎样才能使用枚举来存储在分贝?
此致敬礼!
究竟是什么问题? '@ElementCollection(targetClass = Role.class)'不是必需的。它不是一个集合,而是一个枚举。 – davidxxx
问题是Set,如何坚持所有呢? –
Unlucky
您是否在查找数据库列中的枚举值?这里有一个链接可以帮助你:http://www.codejava.net/frameworks/hibernate/hibernate-enum-type-mapping-example –