Another possible solution for the problem, that in XML your reference
direction is from 1 to many and in SQL it is from many to 1, could be to
make an option in SourceCode generator to generate code where references are
handled bidirectional. So it would be possible to store data that is
unmarshalled from XML direct to SQL by JDO. (But with the behaviour of
setting ArrayLists by calling the get-method and then call ArrayList.add
"outside" the class, it would never be possible to do this.)

How do you handle transfering data from XML to SQL? I've read that there are
people out there that are in the same situation.

Can you give me advice?

Thomas

----- Original Message -----
From: "Thomas Louis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 28, 2002 9:34 AM
Subject: Re: [castor-dev] Found general problem?


> > 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:
>
> No, not magically, but the mapping could provide something like this with
a
> new node-type, I named it "parent-element"
>
> <class name="Child" identity="id" key-generator="MAX" depends="Parent">
>   <map-to xml="child" table="child"/>
>   <field name="id" type="integer">
>     <sql name="child_id"/>
>   </field>
>   <field name="parent" type="Parent">
>     <sql name="parent_id"/>
>     <bind-xml name="parent" node="parent-element"/>
>                                    ^^^^^^^^^^^^
>   </field>
>   <field name="content" type="java.lang.String">
>     <sql name="content" type="varchar"/>
>     <bind-xml name="string" node="text"/>
>   </field>
> </class>
>
> This would be a great solution.
>
> > public void addChild(Child child) {
> >    ...
> >    child.setParent(this);
> > }
>
> Does this also work, if I unmarshall the data from XML. Which method does
> the unmarshaller call to add childs? addChild(Child child)?
setChild(Child[]
> children)? setChild(int index, Child child)?
>
> Thank you,
> Thomas
>
> -----------------------------------------------------------
> 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