增加@ElementCollection中元素的大小

时间:2016-02-04 00:35:29

标签: java mysql hibernate jpa h2

我在JPA中有一个@Entity,其中@ElementCollection就像这样:

@ElementCollection(fetch=FetchType.EAGER)
List<String> photodescription = new ArrayList<>();

问题是默认情况下,任何photodescription的列都是VARCHAR(255)。 我需要将其增加到10000。

是否存在来自@ElementCollection的元素的任何anotation,以设置用于简单字符串的@Size(max=1000)的最大大小?

1 个答案:

答案 0 :(得分:7)

@Column注释仍应适用于此字符串集合:

@ElementCollection(fetch=FetchType.EAGER)
@Column(length=10000) // OR @Column(columnDefinition="VARCHAR(10000)")
List<String> photodescription = new ArrayList<>();