Hi there,
I'm facing this exception.
My code:
Code:
final ReportTemplateAttachment rta = new ReportTemplateAttachment();
FileBlob fb = new FileBlob();
fb.setContentType(attachmentDto.getContentType().getValue());
fb.setCreationDate(sysDate);
fb.setCreationUser(userId);
final SerialBlob blob = new SerialBlob(attachmentDto.getFileVal());//it's a byte[]
//SerialBlob is of type javax.sql.rowset.serial.SerialBlob
fb.setFileData(blob);
fb.setName(attachmentDto.getFileName());
fb.setLastUpdateDate(sysDate);
fb.setLastUpdateUser(userId);
fb.setLength(blob.length());
....
rta.setFileBlob(fb);
and the object rta will be inserted into another object.
The variable of interest in FileBlob hbm is defined as follows:
Code:
<property name="fileData" type="blob">
<column name="FILE_DATA" />
</property>
where the type blob is oracle.sql.BLOB
If I change the oracle.sql.BLOB to javax.sql.rowset.serial.SerialBlob in the hbm, I can insert but when I try to get the blob back I get a deserialize exception so this change is not an option.
but when I save the main Object (a cascade operation) I get the following exception:
Code:
org.springframework.jdbc.UncategorizedSQLException:
Hibernate flushing: could not insert: [pt.sc.data.entities.FileBlob];
uncategorized SQLException for SQL
[insert into WP_ADMIN.file_blob (name, content_type, length, file_data, status, creation_user, creation_date, last_update_user, last_update_date, id)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)];
SQL state [null];
error code [0];
An SQLException was provoked by the following failure: java.lang.ClassCastException:
javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB;
nested exception is java.sql.SQLException: An SQLException was provoked by the following failure:
java.lang.ClassCastException: javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB
Any light on the subject?
Thanks in advance,
mleiria