0

Using:

  • Hibernate Tools 5.2.x (tried 5.2.0.Final and 5.2.9.Final)
  • Hibernate Core-5.2.13.Final.
  • Dialect: org.hibernate.dialect.MySQL57Dialect
  • Spring 5, Spring Boot 2, Gradle

Hibernate tools hbm2java generates this:

@Column(name="domain", nullable=false, length=65535)
    public String getDomain() {
    return this.domain;
}

But validator complains about this:

wrong column type encountered in column [domain] in table [tpd.acl_object]; 
found [text    (Types#LONGVARCHAR)], 
but expecting [varchar(65535) (Types#VARCHAR)]

Detail:

Caused by: org.hibernate.tool.schema.spi.SchemaManagementException: Schema 
 validation: wrong column type encountered in column [domain] in table 
 [tpd.acl_object]; 
 found [text (Types#LONGVARCHAR)], 
 but expecting [varchar(65535) (Types#VARCHAR)]  
 at org.hibernate.tool.schema.internal.AbstractSchemaValidator.validateColumnType(AbstractSchemaValidator.java:159)*

So what gives? Why is the validator not in agreement with Hibernate Tools?

Some solutions say to add columnDefinition=“TEXT” to the get annotation but that cannot be done neither by type mapping nor custom templates. Also, not sure this is a good idea (i.e. to expose the SQL Type up the food chain). So I am guessing the solution is much simpler and I am missing something very obvious because I cannot be the only person using this combination.

Thanks! Alex

MWiesner
  • 8,868
  • 11
  • 36
  • 70
aimass
  • 408
  • 5
  • 11
  • It clearly says it is expecting varchar but you are sending longvarchar. Try to minimize the length, 65535 is really big. – Y.Kaan Yılmaz Mar 03 '18 at 00:48
  • Hi @kaanyılmaz, answer is appreciated but I think you should know why this is so: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-type-conversions.html ... the mapping is not the problem and the size is perfect (is a small text field) the problem seems to be the validator and hibernate tools are not in sync on this one. May be a dialect issue or connection parameter. Waiting for hibernate team's answer on this too: https://discourse.hibernate.org/t/validator-does-not-agree-with-hibernate-tools-reverse-engineering/313 – aimass Mar 03 '18 at 01:14
  • Thanks for the edit @MWiesner I'll know better for next time ;-) – aimass Mar 03 '18 at 01:18

0 Answers0