Hello, Thanks for all the hints till now (I also found a not too old archive about this as well) but I'm still doing something wrong...
Here I attach a very simple extract of my tests, with two mapping files. The refs_attr.xml, where the reference list is handled as attribute node, produces the following exception right during marshalling: java.lang.ClassCastException: org.exolab.castor.mapping.loader.J2CollectionHandlers$IteratorEnumerator The refs_elem.xml, where it is element node, prodices no exception but they are not references during unmarshalling. (OK, the documentation says to use attributes too.) All happens with JDK1.4.1 running in an Eclipse2.0.1 and castor 0.9.3.21 Any idea? regards, Peter <<RefTest.zip>> > ---------- > Von: Keith Visco[SMTP:[EMAIL PROTECTED]] > Antwort an: [EMAIL PROTECTED] > Gesendet: Donnerstag, 21. November 2002 22:50 > An: [EMAIL PROTECTED] > Betreff: Re: [castor-dev] references in collections > > > Hi Peter, > > For Castor XML, references are currently handled via ID/IDREF. > > In order for references to work properly each refereced object must have > a unique id, and any field that is a reference must be marked as such. > For example: > > <class name="Foo"> > <field name="bar" type="Bar"> > <bind-xml node="attribute" reference="true"/> > </field> > ... > </class> > > <class name="Bar" identity="id"> > <field name="id" type="string"/> > ... > </class> > > The 'identity' attribute on the <class> element identifies which field > is the unique id for instances of the class. > > The 'reference' attribute for <bind-xml> indicates that the field is a > reference to another object. > > The following would be an example of the XML for the above mapping: > > <root> > <foo bar="bar1"> > ... > </foo> > <bar id="bar1"> > ... > </bar> > </root> > > I hope that helps. > > --Keith > > Szabo Peter wrote: > > > > Hello, > > > > Thanks but I know how to marshall an ArrayList. > > > > My problem is that my ArrayList contains references. > > (So during unmarshalling they will never to be instantiated but > > just some references to be set.) > > > > It is like: > > 1. you have a Pool of objects > > 2. you have a list of SelectedObjects (and here you hold only > > references to the other list's elements) > > > > But without a mapping file the unmarshalling produces new instances > > in the SelectedObjects list (with the same atribute values of course) > > not references. > > > > rgds, > > Peter >
RefTest.zip
Description: Zip compressed data
