Hi Nresh,

then you have to
- add an ID to your Meeting class
- be sure that before marshalling you set this value to a unique value in
each instance
- in the mapping.xml 
        <class name="[your container class for the collection]">
                <field name="[here once all 'to be referenced objects' as
non references - all references will point back to here]" .../> <!-- you can
omit this field if your VM will keep those Meeting instances with the same
PrimaryKeys until unmarhalling, and you want to store only the references.
But if you have to store+restore the full structure, then you need a basis
to be referenced -->
                ...
                <field name="[the collection's name]" type="Meeting"
collection="collection">
                        <bind-xml name="ObjectList" node="attribute"
reference="true"/>
                </field>
                ...
        </class>
        <class name="Meeting" identity="PrimaryKey">
                <field name="PrimaryKey" type="integer">
                ...
        </class>

your output will be then something like
<Container>
        <Meeting ID="1" .../>
        <Meeting ID="2" .../>
        <Meeting ID="3" .../>
        ...
        <Meeting ID="99" .../>
        <yourCollection ObjectList="1 3 5 8 9">
        ...
</Container>

hope this helps,
Peter

        


> ----------
> Von:  Naresh Bhatia[SMTP:[EMAIL PROTECTED]]
> Antwort an:   [EMAIL PROTECTED]
> Gesendet:     Mittwoch, 12. Februar 2003 01:45
> An:   [EMAIL PROTECTED]
> Betreff:      Re: [castor-dev] Problem with collection of references
> 
> Well, actually I do want to use references. The Meeting objects could be
> referenced from multiple places and I want to make sure only one copy
> per instance is marshelled/unmarshalled.
> Nresh
> 
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, February 11, 2003 7:03 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] Problem with collection of references
> 
> 
> 
> Sounds like you don't want to be using references.
> 
> Just remove reference="true" and make sure you use node="element".
> 
> --Keith
> 
> > Naresh Bhatia wrote:
> > 
> > I am trying to create a collection of references using XML mappings, 
> > but running in to troubles. I have tried two approaches:
> > 
> > Approach 1
> > <field name="meetings" type="Meeting" collection="array">
> >   <bind-xml name="meeting" node="attribute" reference="true"/> 
> > </field>
> > 
> > This gives me
> > <calendar meeting="meeting1 meeting2">
> >   ...
> > </calendar>
> > 
> > Furthermore, the meeting objects are not serialized to the output!
> > 
> > Approach 2
> > <field name="meetings" type="Meeting" collection="array">
> >   <bind-xml name="meeting" node="element" reference="true"/> </field>
> > 
> > This gives me
> > <calendar>
> >   ...
> >   <meeting>meeting1</meeting>
> >   <meeting>meeting2</meeting>
> > </calendar>
> > 
> > Again, the meeting objects are not serialized to the output!
> > 
> > Any idea what I could be doing wrong? I am using Castor 0.9.4.2.
> > 
> > Thanks
> > Naresh
> 
> ----------------------------------------------------------- 
> 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
> 

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

Reply via email to