Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set length of an column in hibernate with maximum length

I want to save an object in data base.
I'm using MySQL data base, but when I try it I get an exception that says: "data is bigger than Column length".
How can I increase the length of my column using hibernate?

like image 265
saeed arash Avatar asked Nov 13 '12 15:11

saeed arash


People also ask

What is the maximum length of column?

Thanks. Best Regards. A TEXT column with a maximum length of 16,777,215 (2 24 âˆ' 1) characters. The effective maximum length is less if the value contains multibyte characters.

What is column length?

The length of the roadway occupied by a column or a convoy in movement. See also road space. Dictionary of Military and Associated Terms.

What is @LOB in hibernate?

The @Lob annotation specifies that the database should store the property as Large Object. The columnDefinition in the @Column annotation defines the column type for the property. Since we're going to save byte array, we're using BLOB.

What is @size in spring boot?

It is flagged with a few standard validation annotations: @Size(min=2, max=30) : Allows names between 2 and 30 characters long. @NotNull : Does not allow a null value, which is what Spring MVC generates if the entry is empty.


2 Answers

if your column is varchar use annotation length

@Column(length = 255) 

or use another column type

@Column(columnDefinition="TEXT") 
like image 130
mychalvlcek Avatar answered Oct 11 '22 07:10

mychalvlcek


@Column(name = Columns.COLUMN_NAME, columnDefinition = "NVARCHAR(MAX)") 

max indicates that the maximum storage size is 2^31-1 bytes (2 GB)

like image 21
user3090074 Avatar answered Oct 11 '22 05:10

user3090074