title: Hibernate schema validation fails with MySQL CHAR mapped to String
body: <p>When using the Hibernate validator to verify that JPA entities match the database schema (typically be setting <code>hibernate.ddl-auto = verify</code>) it will fail when it encounters a MySQL <code>CHAR</code> that has been mapped to a <code>String</code> field.</p>
  
  <p>For example, this MySQL table schema:</p>
  
  <pre><code>CREATE TABLE `item` (
    `id` bigint(20) NOT NULL,
    `name` char(50) DEFAULT NULL,
    PRIMARY KEY (`id`)
  );
  </code></pre>
  
  <p>May be mapped to a JPA entity like this:</p>
  
  <pre><code>@Entity
  public class Item
  {
      @Id
      private Long id;
  
      @Column
      private String name;
  }
  </code></pre>
  
  <p>The verification process will fail with the following exception:    </p>
  
  <blockquote>
    <p><strong>org.hibernate.tool.schema.spi.SchemaManagementException:</strong>
    Schema-validation: wrong column type encountered in column [name] in
    table [item]; found [char (Types#CHAR)], but expecting [varchar(255)
    (Types#VARCHAR)]</p>
  </blockquote>
  
  <p>A typical solution to this is to use the Hibernate <code>@Type</code> annotation on the field to specify the column data type, this works well enough to satisfy the validator:</p>
  
  <pre><code>@Column
  @Type(type = "char")
  private String name;
  </code></pre>
  
  <p>When you actually issue a query that requires mapping a ResultSet to the entity, you will encounter a different set of exceptions (in this case Spring Data was used to issue the query):</p>
  
  <blockquote>
    <p><strong>org.springframework.orm.jpa.JpaSystemException:</strong> Could not set field
    value [B] value by reflection : [class com.example.Item.name] setter
    of com.example.Item.name; nested exception is
    org.hibernate.PropertyAccessException: Could not set field value [B]
    value by reflection : [class com.example.Item.name] setter of
    com.example.Item.name</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p><strong>java.lang.IllegalArgumentException:</strong> Can not set java.lang.String field com.example.Item.name to java.lang.Character</p>
  </blockquote>