0

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?

TastyCode
  • 5,679
  • 4
  • 37
  • 42
  • 2
    Its better to use type of text if you have a long text to store also see this thread [*Is a VARCHAR(20000) valid in MySQL?*](http://stackoverflow.com/questions/1303476/is-a-varchar20000-valid-in-mysql) – M Khalid Junaid Mar 24 '14 at 20:24

1 Answers1

0

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.

TastyCode
  • 5,679
  • 4
  • 37
  • 42