Hi,
 
You need to map either the parent or the children in the mapping, but not both.
 
Otherwise, when you try and marshall the parent from a child, it will then marshal 
that child again and so on, hence the stack overflow.
 
Hope this helps.
 
Patrick

________________________________

From: check-mate [mailto:[EMAIL PROTECTED]
Sent: Sat 28/08/2004 12:55
To: [EMAIL PROTECTED]
Subject: [castor-user] [XML] parent/child relatinship of the same object type




i'm using a parent child relationship of the same object type:

public class Region {
String name;
Collection children;
Region parent;
// omitting the getter and setter methodss
}

lets say i have a tree structure like this:

Europe
|--Germany
|...|--Bayern
|--Austria
|......|--Salzburg
|.........|--North
|.........|--South
|--Italy

and i want to marshal and unmarshal only Austria with exactly on level
of parents and one level of children:

Europe
Austria
Salzburg

when i use a mapping xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<mapping xmlns="http://castor.exolab.org/";
xmlns:cst="http://castor.exolab.org/";>
<description>Castor generated mapping file</description>
<class cst:name="Region"
cst:auto-complete="false">
<description>Default mapping for class Region</description>
<map-to cst:xml="region"/>
<field cst:name="name" cst:type="java.lang.String">
<bind-xml name="name" node="element"/>
</field>
<field cst:name="children" cst:transient="false"
cst:type="Region"
cst:collection="collection">
<bind-xml name="children" node="element">
<class cst:name="Region"
cst:auto-complete="false">
<description>Children mapping for class Region</description>
<map-to cst:xml="region"/>
<field cst:name="name" cst:type="java.lang.String">
<bind-xml name="name" node="element"/>
</field>
<field cst:name="children" cst:transient="true" />
<field cst:name="parent" cst:transient="true"/>
</class>
</bind-xml>
</field>
<field cst:name="kunden" cst:transient="true" />
<field cst:name="benutzer" cst:transient="true"/>
<field cst:name="parent" cst:transient="false">
cst:type="Region">
<bind-xml name="parent" node="element">
<class cst:name="Region"
cst:auto-complete="false">
<description>Parent mapping for class Region</description>
<map-to cst:xml="region"/>
<field cst:name="name" cst:type="java.lang.String">
<bind-xml name="name" node="element"/>
</field>
<field cst:name="children" cst:transient="true" />
<field cst:name="parent" cst:transient="true"/>
</class>
</bind-xml>
</field>
</class>
</mapping>

and when i try to use this mapping i get:
java.lang.StackOverflowError

What am i doing wrong?
. or is this a bug?



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


<<winmail.dat>>

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

Reply via email to