gpt4 book ai didi

java - 增加 @ElementCollection 中元素的大小

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:07:47 25 4
gpt4 key购买 nike

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

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

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

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

最佳答案

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

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

关于java - 增加 @ElementCollection 中元素的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35190467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com