Andy, please see inline ...

Werner

> -----Ursprüngliche Nachricht-----
> Von: Andy Buckley [mailto:[EMAIL PROTECTED]
> Gesendet: Dienstag, 10. April 2007 18:37
> An: [email protected]
> Betreff: Re: [castor-user] What method gets called to add elements to a
> collection?
> 
> Andy Buckley wrote:
> > I've got a problem with using Castor XML and objects which have a
> bidirectional
> > relationship to each other via Java references.
> ...
> > The constructed
> > Paper does have a correct set of Datasets which I can read out, so
> something is
> > working, but none of those Datasets has a valid reference to its parent
> Paper -
> > the thing that would work if Paper.addDataset(...) was being called.
> 
> Can anyone help on this? (*Lots* of details in the previous mail) I
> basically
> just want to know why my Castor mapping for an XML structure like this:
> 
> <paper>
>   <dataset datasetId="1">...</dataset>
>   <dataset datasetId="2">...</dataset>
>   ...
> </paper>
> 
> doesn't seem to call the Paper.setDatasets(...) or Paper.addDataset(...)
> methods during unmarshalling? How *is* the paper's collection of datasets
> getting populated?
Basically, unless you provide an addMethod in the mapping file, Castor XMl - 
for collection types - will by default use the getter method to obtain a 
reference to the collection and call the add() (for e.g. list and set types) 
method on the collection itself.

Things change if you happen to provide an addMethod youself, which will 'force' 
Castor to use the addMethod given to insert elements into the collection.
> 
> I'm using Castor 1.1 - should be bang up to date. We're also using JDOM to
> preprocess the incoming XML, and then using the Castor unmarshaller on the
> DOM node exported from JDOM, rather than unmarshalling directly from 
> the file, if that might make a difference.
No, this should not make any difference, though there's one or two problems 
related to the use of namespaces when unmarshalling from a DOM node.

> 
> Thanks!
> Andy
> 
> --
> Andy Buckley: CEDAR @ IPPP, Durham
> Work: www.cedar.ac.uk
> www.insectnation.org
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
> 
>     http://xircles.codehaus.org/manage_email


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to