Hello All,<br>I've been using hibernate with mysql for a while now with
great success. I searched everywhere and could not find a solution to
this problem, so thanks for any support you can provide.<br><br>I'm
currently storing some data as a byte[] in an object and stored in the
mysql database as a blob. This was seamless with hibernate and had no
issues. I need to now deal with the data as a stream as it's bad form
to carry a 5mb byte[].<br>
<br>I added the methods to the object : <br>java.sql.Blob getBlob() and setBlob( java.jql.Blob) <br>and added the : <br><property name="blob" type="binary" /> (tested with and without the type="binary")<br>
<br>I get the following error if I don't set the blob (would be null)<br>And I recreate the DB each time. I get the following error when inserting the object:<br>Hibernate: insert into AUDIO (bytes, name, contentType, blob) values (?, ?, ?, ?)<br>
Exception in thread "main" org.hibernate.exception<div id="1eqx" class="ArwC7c ckChnd">.SQLGrammarException: could not insert: [com.polling.Audio]<br>Caused
by: java.sql.SQLException: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'blob) values (_binary'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0', null, null, nul' at line 1<br>
<br>And I get the following error if I do set the blob with a simple: audio1.setBlob( Hibernate.createBlob( new byte[1] ) );<br>Exception in thread "main" java.lang.ClassCastException: org.hibernate.lob.SerializableBlob<br>
<br>Environment: <br>Windows Xp sp2<br>java 1.5.0_04<br>Mysql 5.0.20-nt<br>Hibernate 3.2<br><br>Thanks again for any help.<br><font color="#888888"><br>-james</font></div>