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

666 views
Skip to first unread message

Manuel Leiria

unread,
Feb 14, 2012, 6:13:44 AM2/14/12
to ptjug...@googlegroups.com
Bom dia JavaBraniacs :)

Estou aqui com uma situação que passo a explicar:

Vou inserir um objecto na bd que por sua vez tem vários objectos dependentes. A dada altura tenho:

                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());//do tipo byte[]
                fb.setFileData(blob);
                fb.setName(attachmentDto.getFileName());
                fb.setLastUpdateDate(sysDate);
                fb.setLastUpdateUser(userId);
                fb.setLength(blob.length());

depois o meu rta vai ser inserido dentro de outro que por sua vez ainda é inserido dentro de outro. A ideia é utilizar o insert em cascade (hibernate). No hbm do FileBlob, tenho:

 <property name="fileData" type="blob">
            <column name="FILE_DATA" />
 </property>

onde o type blob é oracle.sql.BLOB

quando gravo o objecto principal, recebo a seguinte excepção:

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


alguma alma caridosa sabe dizer-me como resolver isto?

Obrigado
--
Manuel Leiria
Reply all
Reply to author
Forward
0 new messages