【问题标题】:Increase the size of elements in a @ElementCollection增加 @ElementCollection 中元素的大小
【发布时间】:2016-05-13 10:36:30
【问题描述】:

我在 JPA 中有一个 @Entity,它的 @ElementCollection 是这样的:

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

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

对于@ElementCollection 中的元素是否存在任何注释以设置最大大小,例如用于简单字符串的@Size(max=1000)

【问题讨论】:

    标签: java mysql hibernate jpa h2


    【解决方案1】:

    @Column 注释应该仍然适用于这个字符串集合:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-30
      • 2021-07-23
      • 2011-06-13
      • 2019-10-12
      相关资源
      最近更新 更多