Hibernate version:
2.1.7
Stack trace of any exception that occurs:
java.lang.ClassCastException: oracle.sql.BLOB
Name and version of the database you are using:
Oracle9
I got problem with inserting BLOB > 4k into Oracle database.
Example from
http://www.hibernate.org/56.html do not works.
I useTomcata5.5, Hibernate2, Oracle9, Java 1.5.
Did you have the same problem?
Line:
oracle.sql.CLOB clob = (oracle.sql.CLOB) foo.getClob();
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:
Code:
<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"
/>
Expamle code is:
Code:
s = sf.openSession();
tx = s.beginTransaction();
foo = new Foo();
foo.setClob( Hibernate.createClob(" ") );
s.save(foo);
s.flush();
s.refresh(foo, LockMode.UPGRADE); //grabs an Oracle CLOB
oracle.sql.CLOB clob = (oracle.sql.CLOB) foo.getClob();
java.io.Writer pw = clob.getCharacterOutputStream();
pw.write(content);
pw.close();
tx.commit();
s.close();