Hibernate version: 3.1.3
Database type and version: MySQL 5.0
Hi, all!
I'm trying to store byte[] in POJO as an SQL type of blob (in MySQL).
I have the following mapping:
Code:
<property name="thumbnail" type="binary"/>
and my java object has:
Code:
byte[] thumbnail;
This creates
tinyblob in MySQL, but I want to have a type of
blob so I can store an image which size is bigger than what tinyblob can handle.
I tried the following as well.
Code:
<property name="thumbnail" type="blob"/>
While this did create the column with blob type, it did not allow my java object to interact with database (which is understandable i guess since the Hibernate type blob was meant to be used with Blob java type...)
My current work around is that I use binary to let hibernate create the database schema with 'tinyblob' type, then, once the schema is created, i manually change the column type to blob. Hibernate didn't change the column type back to tinyblob. So, it works.
I guess I could implement a customer type, but it seems over-doing it for a simple case like this, and I'm not too confident in implementing a customer type myself.
My question is, is there an easier way to map this byte[] to blob without implementing a customer type?