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
You have to add columnDefinition to @Column annotation, like this:
@Column(name = "DESCRIPTION", nullable = false, length = 65535, columnDefinition="TEXT")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With