Here is a sample xsd and database mapping for clob try it out for blob
it should work.


XSD elemnt: - 

                <xs:complexType>
                        <xs:sequence>
                                <xs:element ref="AccountId"/>   
                                <xs:element ref="XMLText"
minOccurs="0"/>
                                <xs:element ref="ClientNumber"
minOccurs="0"/>
                        </xs:sequence>
                </xs:complexType>

Mapping File Entry: - 

                <field name="accountId" type="long">
                        <sql name="DA_id" type="decimal"
dirty="ignore"/>
                </field>
                <field name="XMLText" type="string">
                        <sql name="XML_TEXT" type="clob"
dirty="ignore"/>
                </field>
                <field name="clientNumber" type="string">
                        <sql name="CLIENT_NBR" type="char"
dirty="ignore"/>
                </field>

Castor will internally manage to create/update/read the clob/blob

http://castor.exolab.org/jdo-mapping.html will give u more details.

All the best 

DNAYNESH



-----Original Message-----
From: Stein M. Eliassen [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 11, 2003 3:47 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] BLOB How-To

Hi!

I'm trying to convert some existing code to Castor for storing files in 
mysql, but it is causing me some headache :-(

I've read http://castor.exolab.org/types.html#BLOB-and-CLOB-Types, but 
still don't get it.

The field is set to stream,  but it seems that only plain text-files is 
working.

The data is written to database for any file, but I must be doing 
something wrong because after loading the object from the database and 
write it to a response-object in a servlet I get a data-format error 
(I'm trying to display an image-file).

Can I initialize the field with a FileInputStream and Castor writes it 
to the database?

How do I use the stream-object after Castor have initialized the field 
after I've loaded the object?

This sounds like basic java-questions, but I have working code that I 
wanted to handle with Castor instead.

Stein

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev



*----------
This message and any attachment(s) is intended only for the use of the addressee(s) 
and may contain information that is PRIVILEGED and CONFIDENTIAL. If you are not the 
intended addressee(s), you are hereby notified that any use, distribution, disclosure 
or copying of this communication is strictly prohibited. If you have received this 
communication in error, please erase all copies of the message and its attachment(s) 
and notify the sender or Kanbay postmaster immediately.

Any views expressed in this message are those of the individual sender and not of 
Kanbay.

Although we have taken steps to ensure that this e-mail and any attachment(s) are free 
from any virus, we advise that in keeping with good computing practice the recipient 
should ensure they are actually virus free.

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to