I have following two classes:
Code:
@Entity(name = "user_table")
public class User {
@Id
@Column(name = "id")
@GeneratedValue
Long id;
@Column(name = "login",nullable = false,unique = true)
private String login;
private Map<UserSettingName, Boolean> settingMap = new HashMap<>();
//other fields
}
public enum UserSettingName {
/*result table specific settings*/
RESULT_TABLE_SHOW_DNS,
RESULT_TABLE_SHOW_SYS_NAME,
RESULT_TABLE_SHOW_IP_ADDRESS,
RESULT_TABLE_SHOW_UPTIME,
RESULT_TABLE_SHOW_DESCRITPION,
RESULT_TABLE_SHOW_SYS_LOCATION
;
}
what annotations should i use on field settingMap. I tried
Code:
@OneToMany( cascade = CascadeType.ALL, orphanRemoval = true)
@MapKeyEnumerated(EnumType.STRING)
but have an error:
nested exception is org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: com.slavick.macmonitor.model.user.User.settingMap[java.lang.Boolean]