Hibernate not recognizing column length in script. Its using default one and giving Data too long for column error

StackOverflow https://stackoverflow.com/questions/22619760

Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top