开发者

Problems with Hibernates hbm2ddl.auto=validate and MySQL text types

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 wi开发者_Python百科th 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


You have to add columnDefinition to @Column annotation, like this:

@Column(name = "DESCRIPTION", nullable = false, length = 65535, columnDefinition="TEXT")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜