Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.sql.rowset.serial.SerialBlob cannot be cast to oracle.sql.BLOB

682538Feb 14 2012 — edited Feb 15 2012
Hi there,

I'm facing this exception.
My 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:
<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:
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2012
Added on Feb 14 2012
4 comments
8,782 views