> Stefan,
>
> Can you provide a small example (the smaller the better) which would
> demonstrate the problem?
Yes of course !
This is the working mapping (it's not much commented yet, if you need that for
understanding, I'll do) :
<class name="SpecBench.CoreData.CategoriesRepository">
<field name="uniqueId" type="int" direct="true">
<bind-xml name="unique-id" node="attribute"/>
</field>
<!-- This is the "big array" I talk about. Note I use reference
here -->
<field name="data" collection="vector" direct="true">
<bind-xml name="data" reference="true" node="element"/>
</field>
<!-- This allows castor to store the tree -->
<field name="root" type="SpecBench.CoreData.Category">
<bind-xml name="root" node="element"/>
</field>
</class>
<class name="SpecBench.CoreData.Category" identity="repositoryId">
<field name="name" type="string">
<bind-xml name="name" node="attribute"/>
</field>
<field name="children" type="SpecBench.CoreData.Category"
collection="vector" get-method="castorGetChildren"
set-method="castorSetChildren">
<bind-xml name="children" node="element"/>
</field>
<field name="parent" type="SpecBench.CoreData.Category">
<bind-xml name="parent" reference="true" node="attribute"/>
</field>
<!-- Some other simple fields... I don't think these have any
influence -->
&repositoryItemsFields;
</class>
-------------------------------------------------------------------------
And now, the mapping that doesn't work :
<class name="SpecBench.CoreData.CategoriesRepository">
<field name="uniqueId" type="int" direct="true">
<bind-xml name="unique-id" node="attribute"/>
</field>
<!-- Big array again, note that i DON'T use reference -->
<field name="data" collection="vector" direct="true">
<bind-xml name="data" node="element"/>
</field>
<field name="root" type="SpecBench.CoreData.Category">
<bind-xml name="root" reference="true" node="attribute"/>
</field>
</class>
<class name="SpecBench.CoreData.Category" identity="repositoryId">
&repositoryItemsFields;
<field name="name" type="string">
<bind-xml name="name" node="attribute"/>
</field>
<field name="children" type="SpecBench.CoreData.Category"
collection="vector">
<bind-xml name="children" reference="true"
node="element"/>
</field>
<field name="parent" type="SpecBench.CoreData.Category">
<bind-xml name="parent" reference="true"
node="attribute"/>
</field>
</class>
have a good read !
Stefan
>
> Thanks,
>
> --Keith
>
> Stefan Champailler wrote:
> > Dear all,
> >
> > I've been using Castor-XML for several month now and I'm happy with it.
> > However,...
> >
> > It seems that the order of an array or vector is not preserved in case
> > that array is told to be stored using reference="true" in the bind-xml
> > element. For example, my situation is like this : I have a tree. Each
> > node of the tree contains a vector of children (standard stuff). However,
> > I have a "big" array in which I put a reference to all the nodes of the
> > tree. Therefore, I have two ways to run the tree : by doing a standard,
> > recursive tree run on each nodes or by looking at the nodes as they are
> > listed in the "big" array. Now, when I store the elements in XML with
> > Castor, I instruct it to store the "big" array, not the elements as a
> > tree-structure (this makes a cleaner XML). Therefore, it stores all the
> > nodes, one by one, ordered as in the big array. Each node's child is
> > represented as a reference (using <bind-xml reference="true"...)
> > Unfortunately, when I do that, Castor looses the order of the elements in
> > each of the vector of children. However, the resulting order is not
> > random, it strictly follows the order in which the nodes appears in the
> > "big" array. So, whatever the order of the children of any node,
> > everything gets reordered according to the big array's order.
> >
> > As a fix, I have told Castor to store the node of the tree recursively,
> > without reference, and after that, to store the "big" array with
> > references to the nodes. Working this way brings the result I expected
> > (however information is duplicated).
> >
> > I checked the bug reports and it seems there are some issues with
> > ordering, but I don't feel I'm connected to those issues. Moreover, I
> > noticed that nowhere in the documentation it is said that the order is
> > preserved, so maybe it's just a feature :)
> >
> > Thank you for any help.
> >
> > stF
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-user
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user