我尝试使用JPA存储一个Map<String, List<String>>
。
我的实体看起来像:
@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
感谢您提前的帮助。