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:oracle:thin:@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();
Adam Maass - 21 Oct 2005 03:56 GMT
> 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