I recently added a new field in an application I'm working on. In MySQL, the column type is binary(64) and in Java, it's a byte[]. When I tried to map the new field in Hibernate, I discovered that Hibernate doesn't seem to have a type that corresponds to MySQL's binary type.
When I try a mapping like this...
Code:
<hibernate-mapping>
<class name="example.Foo" table="foo">
<property name="bar" column="bar" type="binary" />
</class>
</hibernate-mapping>
...HBM2DDL's validation complains
Quote:
Wrong column type in foo for column bar. Found: binary, expected: tinyblob
Adding a length attribute to the <property> changed what type of blob Hibernate expected in the database, but it was always some type of blob, not MySQL's actual binary type. I was able to work around this by nesting a <column> with a sql-type attribute, but I'm still wondering...
Since Hibernate has both a "blob" type and a "binary" type, why do both of those map to MySQL blobs, and no Hibernate type seems to map to a MySQL binary? It almost seems like a bug, or at the very least, a very large oversight. Thoughts?
- Brandon