Hi Luke,
your problem maybe caused by omiting the field names. You defined the
field "id" to be the identity of "Visit" at the class tag but how should
castor know to which field this refers. Could you try to change your
mapping as follows (stripped of some additional attributes to show the
important point):
<class name="org.tri.api.regadt.model.Visit" identity="id">
<map-to table="patreg" />
<field name="id" type="int">
<sql name="patregid" type="int"/>
</field>
<field name="visitaction"
type="org.tri.api.regadt.model.VisitAction"
collection="arraylist">
<sql many-key="patregid" />
</field>
<!-- SNIP UNRELATED STUFF OUT -->
</class>
<class name="org.tri.api.regadt.model.VisitAction" identity="id">
<map-to table="patregaction" />
<cache-type type="count-limited" />
<field name="id" type="int">
<sql name="patregactionid" type="int"/>
</field>
<field name="visit" type="org.tri.api.regadt.model.Visit">
<sql name="patregid" />
</field>
<!-- SNIP UNRELATED STUFF OUT -->
</class>
Now castor knows that identity="id" of Visit class refers to "id" field
which is mapped to "patregid" in "patreg" table. For the VisitAction
class castor finds identity="id" refering to "id" field mapped to
"patregactionid" in "patregaction" table. In addition the VisitAction
class has a field "visit" of type Visit. To find the Visit objects it
uses the data in the column "patregid" of table "patregaction" which
stores the identity of the Visit object. To get a bidirectional mapping
you have the "visitaction" field in the Visit class defined as
arraylist. This field has now corresponding column in "patreg" table but
refers to the column many-key="patregid" of the "patregaction" table.
Hope this helps
Ralf
Galea, Luke schrieb:
Thanks for the suggestion. I am currently using JDO. The mapping is
generated by xdoclet.
So long as I don't declare the foreign key relationship between the
two elements it's fine.
In the mapping below the visit object is represented by the patreg
table whose key field is patregid. patregid is also used as a foreign
key for child "visitactions".
mapping:
<class name="org.tri.api.regadt.model.Visit"
identity="id"
access="read-only"
auto-complete="false">
<map-to table="patreg" />
<field name=""
type="org.tri.api.regadt.model.VisitAction"
get-method="_getVisitActions"
set-method="_setVisitActions"
collection="arraylist">
<sql
many-key="patregid" />
</field>
<!-- SNIP UNRELATED STUFF OUT -->
</class>
<class name="org.tri.api.regadt.model.VisitAction"
identity="id"
access="read-only"
auto-complete="false">
<map-to table="patregaction" />
<cache-type type="count-limited" />
<field name=""
type="org.tri.api.regadt.model.Visit"
get-method="_getVisit"
set-method="_setVisit">
<sql name="patregid" />
</field>
<!-- SNIP UNRELATED STUFF OUT -->
</class>
Ralf Joachim wrote:
Hi Luke,
could you please tell us if you intend to use JDO or XML part of castor
and also post the relevant part of your mapping as this would help
others to understand your problem and suggest a solution.
Ralf
IMPORTANT: The information in this e-mail belongs to Toronto
Rehabilitation Institute and may contain confidential and privileged
information for the sole use of the individual or entity to which it
is addressed. If you are not the intended recipient, you are hereby
notified that any disclosure, copying, or distribution of the contents
of this e-mail is prohibited. If you have received this e-mail in
error, please contact the sender and destroy all copies of the
original message.
Legal Disclaimer
-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty
message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------