Hibernate hbm2ddl.auto=validate 和 MySQL 文本类型的问题
我尝试在我继承的项目上启用 hbm2ddl.auto=validate 。现在,我遇到了许多使用文本或中文本(MySQL 数据库)映射的字符串属性的错误列类型异常。
映射是:
@Column(name = "DESCRIPTION", nullable = false, length = 65535)
@Length(max = 65535)
@NotNull
public String getDescription() {
return this.description;
}
数据库中的数据类型是“text”(utf8_general_ci)。
我认为这应该是正确的映射,但 Hibernate 抱怨它找到了文本,但需要长文本。
我检查了休眠配置,没有指定对话框。我已经添加了
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
,但这似乎没有什么区别。
我知道我可以将 columnDefinition="text" 添加到映射中,但我必须在很多地方这样做,恕我直言,映射应该已经正确了。那么出了什么问题呢?有什么想法吗?
谢谢
I've tried to enable hbm2ddl.auto=validate on a project I've inherited. I now get a lot of wrong column type exceptions for String properties which are mapped either with text or mediumtext (MySQL database).
The mapping is:
@Column(name = "DESCRIPTION", nullable = false, length = 65535)
@Length(max = 65535)
@NotNull
public String getDescription() {
return this.description;
}
And the datatype in the db is 'text' (utf8_general_ci).
I thought this should be the right mapping but Hibernate is complaining that it found text but was expecting longtext.
I've checked the hibernate configuration and there wasn't a dialog specified. I've added
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
but that doesn't seem to make a difference.
I know I can add columnDefinition="text" to the mapping but I would have to do that in a lot of places and IMHO the mapping should be correct already. So what is going wrong? Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将 columnDefinition 添加到 @Column 注释,如下所示:
You have to add columnDefinition to @Column annotation, like this: