I recently upgrade Hibernate from version 3.3.x to 3.6.4. In version 3.3.x validateSchema (hibernate.hbm2ddl.auto=validate) works correctly.
In version 3.6.x validation is broken (tested for 3.6.4 and 3.6.7 as well). The issue is relevant only for field type text.
I redefined the SQL type in my dialect e.g.
public class SQLServer2000UnicodeDialect extends SQLServerDialect {
public SQLServer2000UnicodeDialect(){
super();
// Use Unicode Characters
...
registerColumnType( Types.CLOB, "ntext" );
...
}
}
But during validation, hibernate use original SQL types instead of customized!
Wrong column type in db.dbo.table_name for column a_column. Found: ntext, expected: text
It looks like a bug, but not sure if it is. Maybe I'm missing something in configuration?
P.S. hibernate.hbm2ddl.auto=create/update doesn't works correctly also!
P.P.S. My XML mapping configuration:
<property name="propName" type="text" column="a_column"/>
It's a bit strange, but hibernate somewhere in versions 3.4-3.6 changed binding of "text" mapping (actually hibernate have two types of mapping for long strings: clob and text).
In version 3.3 both mapping (clob and text) were mapped to Types.CLOB
.
In version 3.6 you have to provide separate mapping for text and for clob. Fixing my dialect as shown below solved my issue:
public class SQLServer2000UnicodeDialect extends SQLServerDialect {
public SQLServer2000UnicodeDialect(){
super();
...
registerColumnType( Types.CLOB, "ntext" );
registerColumnType( Types.LONGVARCHAR, "ntext" );
...
}
}