我试图用Map类型的列创建一个表,但出现错误“集合元素映射的列数错误”。下面是供参考的模型:
@Entity
@Table(name = "media")
public class Media {
@NotBlank
private String url;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Long id;
@ElementCollection
private Set<String> textList = new HashSet<String>();
@ElementCollection
private Set<String> tagList = new HashSet<String>();
private String textListText;
private String tagListText;
@ElementCollection
@CollectionTable(name="media_meta_data",joinColumns=@JoinColumn(name="media_id"))
@MapKeyColumn(name="meta_key")
@Column(name="meta_value")
Map<String, Object> metaData= new HashMap<>();
public Map<String, Object> getMetaData() {
return this.metaData;
}
public void setMetaData(Map<String, Object> metaData) {
this.metaData = metaData;
}
}