Hello Bruce,
My mapping.xml file is simple, so I am posting the whole thing. I am
generating the classes from XML so there is no refernce from the child class
to the parent class.
Neil
mapping.xml
----
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
"http://castor.exolab.org/mapping.dtd">
<mapping>
<class name="com.novobase.castor.Minimol" identity="identity"
key-generator="SEQUENCE">
<description>Minimol</description>
<map-to table="minimol"/>
<field name="identity">
<sql name="identity"/>
</field>
<field name="name">
<sql name="name"/>
</field>
<field name="atoms" type="com.novobase.castor.Atoms">
<sql name="atoms"/>
</field>
<field name="bonds" type="com.novobase.castor.Bonds">
<sql name="bonds"/>
</field>
</class>
<class name="com.novobase.castor.Atoms" identity="idJDO"
depends="com.novobase.castor.Minimol" key-generator="SEQUENCE">
<description>Atoms</description>
<map-to table="atoms"/>
<field name="idJDO">
<sql name="identity"/>
</field>
<field name="atomAsReference"
type="com.novobase.castor.Atom" collection="vector">
<sql many-key="idJDO"/>
</field>
</class>
<class name="com.novobase.castor.Bonds" identity="idJDO"
depends="com.novobase.castor.Minimol" key-generator="SEQUENCE">
<description>Bonds</description>
<map-to table="bonds"/>
<field name="idJDO">
<sql name="identity"/>
</field>
<field name="tag">
<sql name="tag"/>
</field>
<field name="bondAsReference"
type="com.novobase.castor.Bond" collection="vector">
<sql many-key="idJDO"/>
</field>
</class>
<class name="com.novobase.castor.Atom" identity="identity"
depends="com.novobase.castor.Atoms" key-generator="SEQUENCE">
<description>Atom</description>
<map-to table="atom"/>
<field name="identity">
<sql name="identity"/>
</field>
<field name="idJDO">
<sql name="idJDO"/>
</field>
<field name="content">
<sql name="content"/>
</field>
</class>
<class name="com.novobase.castor.Bond" identity="identity"
depends="com.novobase.castor.Bonds" key-generator="SEQUENCE">
<description>Bond</description>
<map-to table="bond"/>
<field name="identity">
<sql name="identity"/>
</field>
<field name="idJDO">
<sql name="idJDO"/>
</field>
<field name="name">
<sql name="name"/>
</field>
<field name="origin">
<sql name="origin"/>
</field>
<field name="target">
<sql name="target"/>
</field>
</class>
</mapping>
-----Original Message-----
From: Bruce Snyder [mailto:[EMAIL PROTECTED]]
Sent: 26 November 2002 14:00
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] How to set the foreign key of dependant
objects in XLM generated source code?
This one time, at band camp, Neil Blue said:
NB>Having been digging around with one to many relationship, I have now hit
a
NB>problem. I have an XML Schema that I use to generate my java class source
NB>code. I have attributes whithin the dependant objects to store a
reference
NB>to the parent object.
NB>
NB>My mapping.xml file defines the many-key for the attribute in the
dependant
NB>object that will link to the parent object.
NB>
NB>All this seemed to work fine, I could store and retrieve the object tree.
NB>But when I restarted my server and hence created a new JDO instance with
out
NB>any cached records, I found that my dependant objects were no longer
being
NB>retrieved with their parent objects.
NB>
NB>I looked into the database and found that no foreign key entries has been
NB>saved for the dependant objects. So I looked at the auto generated code,
and
NB>found that this value was not set in the objects. I guess the values
could
NB>be set by castor when it goes to save the object tree, but this does not
NB>seem to happen.
NB>
NB>Is there any way to get castor to populate the dependant objects foreign
key
NB>when it is stored please?
Neil,
This sounds like an issue with your mapping descriptor. Can you
please post the relevant portions of it? Also, are you using
bi-directional relations between your objects?
(http://www.castor.org/jdo-faq.html#bi-directional)
Bruce
--
perl -e 'print
unpack("u30","<0G)U8V4\@4VYY9&5R\"F9E<G)E=\$\!F<FEI+F-O;0\`\`");'
-----------------------------------------------------------
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