This one time, at band camp, Stein M. Eliassen said:
SME>I'm trying to convert some existing code to Castor for storing files in SME>mysql, but it is causing me some headache :-(
SME>
SME>I've read http://castor.exolab.org/types.html#BLOB-and-CLOB-Types, but SME>still don't get it.
SME>
SME>The field is set to stream, but it seems that only plain text-files is SME>working.
SME>
SME>The data is written to database for any file, but I must be doing SME>something wrong because after loading the object from the database and SME>write it to a response-object in a servlet I get a data-format error SME>(I'm trying to display an image-file).
SME>
SME>Can I initialize the field with a FileInputStream and Castor writes it SME>to the database?
SME>
SME>How do I use the stream-object after Castor have initialized the field SME>after I've loaded the object?
SME>
SME>This sounds like basic java-questions, but I have working code that I SME>wanted to handle with Castor instead.
Stein,
How exactly are you handling the LOB? What Java type is the LOB in
your code? When I wrote an app a few years ago that used CLOBs I mapped
them to a java.sql.Clob and in the code I used the java.io.File and the
java.io.FileReader because I pulled files right off of the filesystem. If
my memory serves me, I believe that I did this with both text files
and gifs.
Please post the relevant portions of the object mapping and of your code.
Bruce,
I've discovered that my code was correct, but I had to set cache to "none".
With default cache the blob was written correctly, but the cached data somehow got screwed up when I was writing it to the browser.
Is it possible to have the blob-field in my object to be lazy-loaded or is lazy-loading for collections only?
If it's not possible it's not a problem, I just separate out the blob into an own type.
Cheers Stein
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
