Thomas Louis wrote:
> 
> Hello Keith,
> 
> > Hi Thomas,
> >
> > I couldn't figure out if you are trying to use the Unmarshalling to fill
> > the parent field...
> >
> > if so:
> >
> > You have to mark the 'parent' field as a reference and change the node
> > type to attribute:
> >
> > ...
> >    <field name="parent" type="Parent" reference="true">
> >      <sql name="parent_id"/>
> >      <bind-xml name="parent" node="attribute"/>
> >    </field>
> > ...
> >
> > the XML representation must also be an attribute containing the id of
> > the parent,
> > as such:
> >
> > <parent id="x">
> >    <child parent="x">one</child>
> >    <child parent="x">two</child>
> > </parent>
> 
> Exactly this is, what I tried to prepend. I think XML has a tree-structure
> to say <child> is a child of <parent> if it is a subelement. So why does
> castor not have a possibility to define a backreference to a parent-element
> if one specify this in the mapping file. How to take Data from XML to SQL
> else?
> 

Castor has no way to "magically" guess that you want to put a copy of
the parent inside the child. So you can either use the approach I
suggested above which explicitly expresses your desires, or you can
handle the back-reference very easily yourself in your add/set method:


public void addChild(Child child) {
   ...
   child.setParent(this);
}

--Keith

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

Reply via email to