Hibernate version: 3.0.5
Code between sessionFactory.openSession() and session.close():
session.save(video);
Full stack trace of any exception that occurs:
Code:
Exception in thread "main" java.lang.UnsupportedOperationException: Blob may not
be manipulated from creating session
at org.hibernate.lob.BlobImpl.excep(BlobImpl.java:104)
at org.hibernate.lob.BlobImpl.getBytes(BlobImpl.java:50)
at org.hibernate.lob.SerializableBlob.getBytes(SerializableBlob.java:35)
at com.mysql.jdbc.PreparedStatement.setBlob(PreparedStatement.java:305)
at fapesp.hibernate.BinaryBlobType.nullSafeSet(BinaryBlobType.java:39)
at org.hibernate.type.CustomType.nullSafeSet(CustomType.java:141)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEn
tityPersister.java:1617)
at org.hibernate.persister.entity.BasicEntityPersister.dehydrate(BasicEn
tityPersister.java:1594)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntit
yPersister.java:1850)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntit
yPersister.java:2200)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.ja
va:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutio
ns(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlus
hEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at fapesp.hibernate.InserirVideo.inserirPuroHibernate(Unknown Source)
at fapesp.hibernate.InserirVideo.main(Unknown Source)
Name and version of the database you are using:
PostgreSQL 8.1, MySQL 4.1
Hello, guys, well, I'm having some troubles on inserting video files in some databases...
I know you all think that this forum has enough questions about blobs, but here am I with another one :)
Well, I've inserted a video (40mb) to a PostgreSQL database, using "oid" sql-type and BinaryBlobType (
http://www.hibernate.org/73.html ). It took 19 seconds.
The same operation (mapping sql-type to longblob) in a MySQL database throws the exception above.
Reading the forums, I found that mapping the type to binary would work, and did. But the same insert video operation now takes 60 seconds using binary instead of BinaryBlobType!
I don't know how blobs are manipulated, I just know that they're pointers to anywhere-I-don't-know-where, instead of long arrays of bytes. maybe this difference is the reason to the lost of performance.
So.. what this exception means? Why this exception is thrown just when using MySQL?
Anywhere could explain me?
Thanks, and sorry for any English errors, I'm still learning... :)