Hibernate version: hibernate-3.0rc1, hibernate-annotations-3.0alpha3
I have a POJO which has a property like the following. I found that when I run SchemaExport to create the database schema that it sets the SQL data type to tinyint.
Code:
public byte[] getCV() {
return cv;
}
I'm able to specify that the data type should be longblob using the following annotation.
Code:
@Column(columnDefinition="longblob")
However, when, I attempt to persist the object, I receive the following exception. I think it's basically treating the byte[] as a byte instead.
Code:
Caused by: java.lang.ClassCastException: [B
at org.hibernate.type.ByteType.set(ByteType.java:38)
I found the following link which describes how to deal with BLOBs using a custom UserType and a mapping file. What I'm wondering is if I'll need to use a mapping file to do what I want to do?
[url]http://www.hibernate.org/73.html
[/url]
The other thing that I'm wondering is if there is a DBMS independent way to deal with BLOBs? Or, is it the case that you pretty much have to write DBMS specific code when using BLOBs? If it's the later, I'll probably just store the data in the file system instead.