Hibernate无法识别脚本中的列长度。(Hibernate not recognizing column length in script. Its using default one and g

编程入门 行业动态 更新时间:2024-10-28 12:24:40
Hibernate无法识别脚本中的列长度。(Hibernate not recognizing column length in script. Its using default one and giving Data too long for column error)

我使用脚本生成表而不是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=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?

最满意答案

问题与另一张表有关。 我们还有一个包含字段'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.

更多推荐

本文发布于:2023-08-06 05:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1443579.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   长度   无法识别   column   recognizing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!