[jboss-user] [JBoss Tools (users)] - Hibernate validation failure with Seamgen/MYSQL

bdlink do-not-reply at jboss.com
Tue Dec 9 18:21:36 EST 2008

This is not new, and may belong with the hibernate people (just tell me).

Using windows XP, latest daily build of JBT 3.

Have a mysql database with a fixed width field STATE char(2) and some varchar fields. (mysql shows the column type for STATE as char(2))

Seam gen entities generates (in the code)
 	@Column(name = "STATE", length = 2)
	@Length(max = 2)
(similarly for the varchar fields, no difference other than the 2 lengths)
In the persistence.xml, seamgen generates
Application fails to load with following traceback (partial):
Caused by: org.hibernate.HibernateException: Wrong column type: STATE, expected: varchar(2)
  | 	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.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:713)
I note that in the JBDS 2 Beta 1, the persistence.xml is autogenerated with update, not validate.  I can make the error go away by adding columnDefinition="char(2)" to the column attribute.  

I guess I feel generate entities should generate correct entities in the presence of fixed length character fields.  

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4195450#4195450

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4195450

More information about the jboss-user mailing list