Hibernate Version :2.9.5
IDE:NetBeans 6.5
Oracle:10g
Jar used:classes12.jar
I reverse engineered and created my hbm file and java files.
I have one table having a Blob field.Reverse mapping registered it as a
serializible type.I can now insert data into it but cannot retrieve from it,It shows a Hibernate exception,invalid conversion required.
So I changed the type to Blob. and now I can read data from database but cannot insert.
The error I am getting is :Blob may not be manipulated from creating session
Before that editing I got cannot serialize error.
I tried UserTypes described in Hibernate.org. But got the same error.
Now what should I do to get rid of this issue.
My hbm file [snippet is]
Code:
<property name="image" type="hibernateimaged.BlobType">
<column name="IMAGE"/>
</property>
Where BlobType is the class that implements UserType
The code which I am trying to execute
Code:
public void saveImage(byte[] image) throws SQLException
{
SessionFactory factory = HibernateUtil.getSessionFactory();
Session session = factory.getCurrentSession();
Blob myimage=Hibernate.createBlob((byte[]) image);
myimage.setBytes(1, image);
session.beginTransaction().begin();
TestBlob bilobe=new TestBlob(); //This is my mapped Class
bilobe.setId((long)1028);
bilobe.setFileName("FileName");
bilobe.setUsername("UserName");
bilobe.setTimestamp(new Date(1,1,1993));
bilobe.setImage(image);
session.save(bilobe);
session.getTransaction().commit();
}
[/code]