I'm new to the hibernate world and I am using it to map a table that stores files of all types. I am however recieving a very strange error:
javax.servlet.ServletException: java.lang.ClassCastException: [B cannot be cast to java.sql.Blob
I have mapped my MySql LONGBLOB column has: <property name="fileData" type="blob" .../>
and <property name="fileData" type="longblog" .../>
but both don't work.
I'm currently using spring mvc version 3.x the latest version and tomcant 7 if that helps.
edit: here is how my POJO looks like for fileObject:
package com.kc.models;
public class FileObject {
private String fileName;
private String type;
private double size;
private byte[] file;
private int id;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public double getSize() {
return size;
}
public void setSize(double size) {
this.size = size;
}
public byte[] getFile() {
return file;
}
public void setFile(byte[] file) {
this.file = file;
}
}
And here is how my hbm.xml file looks like:
<class name="com.kc.models.FileObject" table="FILES">
<id name="id" column="ID">
<generator class="native" />
</id>
<property name="fileName" type="string" column="FILENAME" />
<property name="type" type="string" column="TYPE" />
<property name="size" type="double" column="SIZE" />
<property name="file" type="blob" column="FILE" />
</class>
O and here is a print screen of mySql: http://img412.imageshack.us/img412/3663/fileobject.jpg