|
Hi,
I would like to know whether Castor can
marshal/unmarshal objects which are connected through a bidirectional
aggregation relationship. Consider these two classes:
public class Order {
java.util.Set items;
// Items of these order
public void setItems (Set
items)
{
this.items =
items;
}
public Set
getItems()
{
return
items;
}
}
public class Item {
Order order; // The order this
item belongs to
public void setOrder (Order
order)
{
this.order =
order;
}
public Order
getOrder()
{
return
order;
} }
My mapping file looks like this:
<mapping>
<class name="Order"
auto-complete="true">
<field
name="items" type="Item" collection="set">
</field>
</class>
<class name="Item"
auto-complete="true">
<field
name="order" type="Order">
</field>
</class> </mapping>The following test case fails with "Process exited
with code 128":
Order ord = new Order();
Item item1 = new Item();
Item item2 = new Item();
Set items = new HashSet();
items.add(item1);
items.add(item2);
ord.setItems(items);
item1.setOrder(ord);
item2.setOrder(ord);
Mapping mapping = new Mapping();
mapping.loadMapping("castor-mapping.xml");
FileWriter writer = new
FileWriter("order.xml");
Marshaller marshaller = new
Marshaller(writer);
marshaller.setMapping(mapping);
marshaller.marshal(ord);
Any ideas what the problem is?
Regards,
Vahan Harput
|
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
