title: Hibernate validation issue for blob sql type
body: <p>I'm getting the following error:</p>
  
  <pre><code>Caused by: org.hibernate.HibernateException: Wrong column type in PUBLIC.PUBLIC.ALL_TYPES_ENTITIES for column blob1. Found: varbinary, expected: blob(255)
      at org.hibernate.mapping.Table.validateColumns(Table.java:383)
  </code></pre>
  
  <p>I'm creating table using liquibase:</p>
  
  <pre><code>        &lt;column name="blob1" type="BLOB"&gt;
              &lt;constraints nullable="true"/&gt;
          &lt;/column&gt;
  </code></pre>
  
  <p>The java entity has a field:</p>
  
  <pre><code>private byte[] blob1;
  ...
  @Basic(fetch = FetchType.LAZY)
  @Lob
  @Column(name = "blob1")
  public byte[] getBlob1() {
      return blob1;
  }
  </code></pre>
  
  <p>I'm using hsqldb 2.2.9 as a database and Hibernate 3.5.0-Final as a JPA provider. Hibernate dialect for hsqldb is:</p>
  
  <pre><code>&lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.HSQLDialect&lt;/prop&gt;
  </code></pre>
  
  <p>When liquibase generates a table, the liquibase HsqlTypeConverter should use VARBINARY as sql type.
  WHen Hibernate validate scheme it thinks that type is blob(255), compares it with VARBINARY and throws exception.</p>
  
  <p>Here is code that validates the table:</p>
  
  <pre><code>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(
  ...
  </code></pre>
  
  <p>In debugger I can see when exception is thrown, that <code>col.sqlType = blob(255)</code>, <code>columnInfo.typeName = VARBINARY</code>. For some reason when <code>col.getSqlType( dialect, mapping )</code> is invoked to init col.sqlType, it gets blob(255). 
  I suppose that I should update hsqldb dialect in the hibernate configuration. But not sure.
  Don't know what should I do to resolve the problem. </p>