You can do the below mentioned workaround using a custom FieldHandler,
This will allow you to marshal keys and values yet not change your
object model.

There has been examples of this in the mailing list in the past.

--Keith

Gregory Fox wrote:
> 
> Unfoturnately, I can't change the model to match the
> persistence mechanism.
> 
> --- [EMAIL PROTECTED] wrote:
> > Somewhere in the docs there is mentioned that
> > hashmap's / tables are not
> > marshaled properly. In the marshalling process the
> > key gets discarded.
> >
> > One workaround could be:
> >
> > Have a method called getEntries() and one called
> > setEntries(). Have
> > these then take / return a Entry[] as argument, with
> > an Entry being
> > something like:
> >
> > public class Entry
> > {
> >       Object key;
> >       Object value;
> > }
> >
> > and have those two methods then work on your hashmap
> > / table.
> >
> > Good luck
> >
> > --Alex
> >
> > -----Original Message-----
> > From: Gregory Fox [mailto:[EMAIL PROTECTED]
> > Sent: 17 June 2003 06:08
> > To: [EMAIL PROTECTED]
> > Subject: [castor-dev] Can't figure out HashMap
> >
> > I am having a few problems getting my Business Model
> > to work with Castor.  In this message I will ask
> > about
> > my HashMap problem.  It currently comes out as shown
> > below without the "key" being saved.  It of course
> > can't be read back in in this format.  What do I
> > need
> > to do to get this stored out properly.
> >
> > <myStrategy xsi:type="mySpecialStrategy">
> >     <attributes
> > xsi:type="java:java.lang.String">6</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">2</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">4</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">7</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">1</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">3</attributes>
> >     <attributes
> > xsi:type="java:java.lang.String">5</attributes>
> > </myStrategy>
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> >
> >
> -----------------------------------------------------------
> >
> > If you wish to unsubscribe from this mailing, send
> > mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> >
> >
> -----------------------------------------------------------
> >
> > If you wish to unsubscribe from this mailing, send
> > mail to
> > [EMAIL PROTECTED] with a subject of:
> >         unsubscribe castor-dev
> >
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to