The problem was related to another table. We have an audit table with field 'description' also. Once i increased the size of the audit table description field the error went away. Unfortunately the error thrown by hibernate did not state on which table the error was thrown and i assumed it was on the regular table.
Hibernate not recognizing column length in script. Its using default one and giving Data too long for column error
-
20-06-2023 - |
Вопрос
I am using scripts to generate tables instead of hibernate auto generate. There is a varchar column with length 5000
create table my_code (
cc_id bigint not null auto_increment unique,
description varchar(5000),
primary key (cc_id)
) ENGINE=InnoDB
In my class i have a description field:
@Column(name = "description", length=5000)
private String description;
But when i insert a field with length 300 it throws:
Data truncation: Data too long for column 'description' at row 1
It accepts anything below 255 which is the default. Why is it not picking up length 5000?
Решение
Не связан с StackOverflow