Details
-
Type: Bug
-
Status: Closed
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
Testcase:
public void testConverter()
Gebruikers.xml
<java.util.ArrayList>
<nl.politie.isc.h2o.framework.service.mock.domein.Kind id="nl.politie.isc.h2o.framework.service.mock.domein.Kind_1">
<id>1</id>
<naam>kindnaam </naam>
<moeder reference="nl.politie.isc.h2o.framework.service.mock.domein.Moeder_1"/>
</nl.politie.isc.h2o.framework.service.mock.domein.Kind>
<nl.politie.isc.h2o.framework.service.mock.domein.Moeder id="nl.politie.isc.h2o.framework.service.mock.domein.Moeder_1">
<id>1</id>
<naam>moedernaam </naam>
<kind reference="nl.politie.isc.h2o.framework.service.mock.domein.Kind_1"/>
</nl.politie.isc.h2o.framework.service.mock.domein.Moeder>
</java.util.ArrayList>
In this case the 'Moeder' object has a reference to the 'Kind' object, but the other way arround the reference seems not to work only a null value can be found.
It seems like I can only up in the xml document tree, but not down.
What am I doing wrong. In the document circular reference is mentioned serveral times.
XStream is stream based (rather than document based), meaning it handles deserializes each object as soon as it encounters it in the XML.
This means that whenever a 'reference' is encountered, XStream needs to have already deserialized the object that the reference is pointing to, otherwise it cannot continue.
The XML you posted can be restructured to allow this:
<java.util.ArrayList>
<nl.politie.isc.h2o.framework.service.mock.domein.Kind id="nl.politie.isc.h2o.framework.service.mock.domein.Kind_1">
<id>1</id>
<naam>kindnaam </naam>
<moeder id="nl.politie.isc.h2o.framework.service.mock.domein.Moeder_1">
<id>1</id>
<naam>moedernaam </naam>
<kind reference="nl.politie.isc.h2o.framework.service.mock.domein.Kind_1"/>
</moeder>
</nl.politie.isc.h2o.framework.service.mock.domein.Kind>
<nl.politie.isc.h2o.framework.service.mock.domein.Moeder reference="nl.politie.isc.h2o.framework.service.mock.domein.Moeder_1"/>
</java.util.ArrayList>