|
I am reverse engineering my annotated POJO's from a MySQL database schema. The table (simplified for the purpose of brevity) has the following field:
component
------------
...
description | text
...
The Hibernate reverse engineering tools created this in the POJO:
@Entity
@Table(name="component")
public class Component implements java.io.Serializable {
....
@Column(name="description", length=65535)
public String getDescription() {
return this.description;
}
....
}
That's fine because the 'text' MySQL datatype is effectively a VARCHAR(65535). However, now when I startup my webapp, running in Tomcat 5, using MySQL 5 JDBC JAR file and org.hibernate.dialect.MySQL5Dialect, I get the error indicated in the subject line above.
Full stack trace is:
Caused by: org.hibernate.HibernateException: Wrong column type: description, expected: varchar(65535)
at org.hibernate.mapping.Table.validateColumns(Table.java:261)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1083)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:116)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:317)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:799)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:733)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1257)
... 50 more
I've tried on suggestion which was to subclass the dialect class and register the varchar type as text, but that didn't help. Still get the exception. Can anybody shed light on the cause of my problem. Please. Any help appreciated as this is really frustrating me right now.
Many thanks,
Darryl Pentz
|