Hi all,
While i am trying to insert a blob field using hibernate, I am getting this exception
Code:
java.lang.UnsupportedOperationException: Blob may not be manipulated from creating session
Here is my code..
Code:
Session sess = HibernateUtil.getSessionFactory().openSession();
byte[] data = getParamByteData(); //Here i am getting byte array for blob field
Parameters params = new Parameters("Test", data);
Transaction transaction = null;
try {
transaction = sess.beginTransaction();
sess.save(params);
transaction.commit();
} catch (Exception e) {
e.printStackTrace();
//System.out.println("Select exception in DM : " + e);
}
Parameters.java Code:
public class Parameters {
private int paramId;
private String paramName;
private byte []paramFile;
public Parameters(String paramName, byte[] paramFile) {
.
.
..
parameters.hbm.xmlCode:
<hibernate-mapping>
<class name="com.test.blob.db.Parameters" table="parameters">
<id name="paramId" column="param_id" type="int">
<generator class="increment"/>
</id>
<property name="paramName">
<column name="param_name" sql-type="string"/>
</property>
<property name="paramFile" column="param_file" type="com.test.blob.db.BinaryBlobType"/>
</class>
</hibernate-mapping>
Could any body help me out...