Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase the size of elements in a @ElementCollection

I have an @Entity in JPA which has a @ElementCollection like this:

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

The problem is that by default, the Column for any photodescription is a VARCHAR(255). I need to increase that to 10000.

Exists any anotation for the elements from a @ElementCollection to set a maximum size like @Size(max=1000) which is used for a simple String?

like image 362
Alberto Crespo Avatar asked Dec 19 '22 20:12

Alberto Crespo


1 Answers

The @Column annotation should still work for this collection of strings:

@ElementCollection(fetch=FetchType.EAGER)
@Column(length=10000) // OR @Column(columnDefinition="VARCHAR(10000)")
List<String> photodescription = new ArrayList<>();
like image 108
David Yee Avatar answered Dec 21 '22 10:12

David Yee