HIBERNATE, ORACLE, BLOB > 4k

C

chomiq

How to put blob ( > 4k ) into Oracle9 using Hiberanete?

I got problem with inserting BLOB > 4k into Oracle database.

Example from http://www.hibernate.org/56.html do not works.

I use Tomcata5.5, Hibernate2.1.7, Oracle9, Java 1.5.

This line in my code:
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);

throws ClassCastException , why??

Is any other way to insert Blob into Oracle?

Do I have to use some other driver then oracle.thin ?
My context.xml looks like:

<Resource
name="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
username="migration"
password="***"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:eek:racle:thin:mad:123.123.123.123:2222:TEST"
maxActive="100"
maxIdle="10"
maxWait="3000"
/>


Code is:

session = HibetnateUtil.currentSession();
tx = sessison.beginTransaction();
....
atta.setData( Hibernate.createBlob("temporary".getBytes()) );
session.save(atta);
session.flush();
byte[] temp = atta.getBytes();
session.refresh( atta, LockMode.UPGRADE );
( (oracle.sql.BLOB)atta.getData() ).putBytes(0,temp);
tx.commit();
session.flush();
 
A

Adam Maass

chomiq said:
How to put blob ( > 4k ) into Oracle9 using Hiberanete?

Please google before posting questions that have obvious answers at obvious
places.

To save you the effort:

http://www.hibernate.org/56.html


Now, a slightly longer answer:

Oracle LOBs do not behave in the way that the authors of the SQL spec or the
JDBC spec expect. Oracle, to their credit, does a decent job of documenting
what you must do to make LOBs work in Oracle. Note that you will be spinning
a lot of custom code just for Oracle to use Oracle LOB types.


-- Adam Maass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top