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

I tried to enable hbm2ddl.auto = validate in a project that I inherited. Now I get many incorrect column type exceptions for String properties, which are displayed either using text or as text material (MySQL database).

Display:

@Column(name = "DESCRIPTION", nullable = false, length = 65535) @Length(max = 65535) @NotNull public String getDescription() { return this.description; } 

And the data type in db is "text" (utf8_general_ci).

I thought this should be the correct display, but Hibernate complains that it found the text but was expecting a longtext.

I checked the sleep configuration and no dialog box was specified. I added

 <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> 

but that doesn't seem to matter.

I know that I can add columnDefinition = "text" to the mapping, but I would have to do this in many places, and IMHO the correct display. So what's going wrong? Any ideas?

thanks

+4
source share
1 answer

You need to add columnDefinition to the @Column annotation, for example:

 @Column(name = "DESCRIPTION", nullable = false, length = 65535, columnDefinition="TEXT") 
+4
source

All Articles