public void validateColumns(Dialect dialect, Mapping mapping, TableMetadata tableInfo) {
Iterator iter = getColumnIterator();
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
ColumnMetadata columnInfo = tableInfo.getColumnMetadata( col.getName() );
if ( columnInfo == null ) {
throw new HibernateException( "Missing column: " + col.getName() + " in " + Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()));
}
else {
final boolean typesMatch = col.getSqlType( dialect, mapping ).toLowerCase()
.startsWith( columnInfo.getTypeName().toLowerCase() )
|| columnInfo.getTypeCode() == col.getSqlTypeCode( mapping );
if ( !typesMatch ) {
throw new HibernateException(
"Wrong column type in " +
Table.qualify( tableInfo.getCatalog(), tableInfo.getSchema(), tableInfo.getName()) +
" for column " + col.getName() +
". Found: " + columnInfo.getTypeName().toLowerCase() +
", expected: " + col.getSqlType( dialect, mapping )
);
}
}
}