我正在尝试存储一个Map<String, List<String>>
;使用 JPA。
我的实体看起来像:
@Entity
@Table(name = "Profiles_table")
public class Profiles {
@Id
@Column(name = "profile_ID", updatable = false, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
private final HashMap<String, List<String>> AllProfiles;
...
}
我已经为地图尝试了很多设置,但它不起作用......
我尝试的最后一个:
@ElementCollection
@MapKeyColumn(name = "Profil")
@Column(name = "Permissions")
@CollectionTable(name = "Profiles_permissions", joinColumns = @JoinColumn(name = "profile_ID"))
抛出以下异常:
org.hibernate.AnnotationException: Illegal attempt to map a non collection as a
@OneToMany, @ManyToMany or @CollectionOfElements: [...]Profiles.AllProfiles
提前致谢