Hi,

The Unmarshaller.setReuseObjects(boolean) also applies when graphs of
objects are stored?  Some time ago, I posted a similar problem, and a
suggested solution was a mapping file using "reference" and "identity" in
conjunction... but I found it was not straight forward (I may be doing
something wrong), since it seemed to be necessary to add a method to my
classes to provide and objectID. Below I include a very basic mapping file
to ilustrate this.

1) is this the right aproach?  Should I use set Unmarshaller.ReuseObjects
instead?
2)Is there any way to avoid modifying my classes adding an extra method?


<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN"
                           "http://castor.exolab.org/mapping.dtd";>
<mapping>

  <!--  Mapping for Person  -->
  <class name="castortest.Person" identity="id">

    <field name="id" type="string" >
      <bind-xml node="attribute"/>
    </field>

    <field name="name" type="string">
       <bind-xml node="attribute" />
    </field>

    <field name="friend" type="castortest.Person">
       <bind-xml node="attribute" reference="true"/>
    </field>

  </class>

</mapping>


Thanks a lot!
Hans


----- Original Message -----
From: "Keith Visco" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 27, 2002 5:45 AM
Subject: Re: [castor-dev] Question: Marshalling/Unmarshalling Object
Structures...


>
>
> "Quinn, Kim John" wrote:
> >
> > Hello everyone,
> >
> > Testing out Castor for potential use and so far think its great but I
have a
> > 2 questions:
> >
> > Let's say for instance I have the following structure:
> >
> > Class A, with 2 children B and C...so
> >
> > --Person
> >     |
> >     |--1---*-->ContactMethod
> >     |
> >     |--1---*-->Address
> >
> > I create a new instance, fill the values for all objects, store it, then
> > marshall it out to XML...that works fine.
> >
> > QUESTION 1: Now, I want to unmarshall the XML "back into" this
> > structure....do I have to manually iterate the children because only my
root
> > object is getting "updated?"  The children are all being inserted as
new.
> >
>
> You might want to try the CVS version...I added initial support for
> Unmarshaller#setReuseObjects(boolean) which, when set to true, will
> try to reuse exising objects within the tree. Simple tests are working
> for me. I haven't had a chance to do extensive testing....
>
> --Keith
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to