I'm trying to use hibernate to read / write blobs in a Oracle9 database.
The mappings is very simple:
Code:
<class
name="TBlobs"
table="TBLOBS"
dynamic-update="true">
...
<property
name="data"
type="blob"
column="DATA"/>
...
The corresponding java class looks like
Code:
public class TBlobs implements Serializable {
...
private Blob fData;
public Blob getData() {
return fData;
}
public void setData(Blob data) {
fData = data;
}
...
Nothing fancy in the hibernate configuration (I tried with and without hibernate.jdbc.use_streams_for_binary ) with the following parameters:
Code:
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:...
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
My code (to insert a blob) looks like :
Code:
...
Session sess = factory.openSession();
Transaction t = sess.beginTransaction();
TBlobs b = new TBlobs();
Blob blob = Hibernate.createBlob(stream);
b.setData(blob);
sess.save(b);
t.commit();
At runtime, I got the following error:
2969 [main] WARN util.JDBCExceptionReporter - SQL Error: 17090, SQLState: null
2969 [main] ERROR util.JDBCExceptionReporter - operation not allowed: streams type cannot be used in batching
2984 [main] ERROR util.JDBCExceptionReporter - Could not synchronize database state with session
The SQL generated looks like:
Hibernate: insert into TBLOBS (NAME, DATA, ID) values (?, ?, ?)
What am I doing wrong here?