我使用脚本生成表而不是hibernate auto generate。 有一个长度为5000的varchar列
create table my_code ( cc_id bigint not null auto_increment unique, description varchar(5000), primary key (cc_id) ) ENGINE=InnoDB在我的课上,我有一个描述字段:
@Column(name = "description", length=5000) private String description;但是当我插入一个长度为300的字段时,它会抛出:
数据截断:第1行的列“描述”的数据太长
它接受低于255的任何默认值。 为什么它不会长度5000?
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=InnoDBIn 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?
最满意答案
问题与另一张表有关。 我们还有一个包含字段'description'的审计表。 一旦我增加了审计表描述字段的大小,错误就消失了。 不幸的是,hibernate抛出的错误没有说明错误被扔到哪个表上,我认为它是在常规表上。
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.
更多推荐
发布评论