Keith-

Thanks a million- It does indeed work!!
I see the problem was in my mapping.xml-
I still wish I could put the ID and REF as elements
rather than as attributes (to accomodate a current xml
project I am working on)- but oh well- I will use this
for future reference-

thanks alot again for your patient help....Now if I
can just get my mapping to util.Date to work...:)-

Jim




--- Keith Visco <[EMAIL PROTECTED]> wrote:
> 
> 
> Hi Jim,
> 
> To prevent spamming the list with an attachment, I
> sent a working
> example directly to your e-mail address. If anyone
> else is interested in
> the answer..let me know and I'll send the example to
> you as well.
> 
> --Keith
> 
> Jim Otte wrote:
> > 
> > Keith,
> > Yes, please send me the working example as I have
> > tried to change the mapping to:
> > <mapping>
> >         <class name="Foo" identity="id">
> >                 <map-to xml="foo"/>
> >                 <field name="id" type="int">
> >                         <bind-xml name="id"
> node="attribute"/>
> >                 </field>
> >                 <field name="bar" type="Bar">
> >                         <bind-xml name="bar"
> node="element"/>
> >                 </field>
> >         </class>
> >         <class name="Bar">
> >                 <map-to xml="bar"/>
> >                 <field name="greeting"
> type="java.lang.String">
> >                         <bind-xml name="greeting"
> node="element"/>
> >                 </field>
> >                 <field name="parent" type="Foo" >
> >                         <bind-xml name="foo"
> reference="true" />
> >                 </field>
> >         </class>
> > </mapping>
> > 
> > and xml:
> > 
> > <foo id="42">
> >         <bar foo="42">
> >                 <greeting>hello world</greeting>
> >         </bar>
> > </foo>
> > 
> > with the same classes- but still get with
> > System.out.println(foo.getBar().getGreeting());
> > 
> >
>
System.out.println(foo.getBar().getParent().getId());
> > 
> > the result:
> > hello world
> > java.lang.NullPointerException
> > 
> > If you have something that "woks" I would much
> > appreciate it- or point out what I am doing
> > incorrectly-
> > 
> > Jim
> > 
> > --- Keith Visco <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >
> > >
> > > Keith Visco wrote:
> > > >
> > > > Hi Jim,
> > > >
> > > > Yes you need to change the input XML, which
> must
> > > contain the "foo"
> > > > reference:
> > > >
> > > > It should look something like the following:
> > > > <foo id="42">
> > > >    <bar foo="42">
> > > >       <greeting>hello world</greeting>
> > > >    </bar>
> > > > </foo>
> > >
> > > That should read:
> > >
> > >  <foo id="42">
> > >     <bar parent="42">
> > >        <greeting>hello world</greeting>
> > >     </bar>
> > >  </foo>
> > >
> > > I do have a working example of this if you want
> me
> > > to send it to you.
> > >
> > > --Keith
> > >
> > > >
> > > > When you marshal from Castor you'll see that
> > > Castor creates the XML like
> > > > this.
> > > >
> > > > Currently this is the only way to get Castor
> to
> > > automatically put the
> > > > Foo parent instance into Bar.
> > > >
> > > > In the future we may have something that will
> do
> > > it automatically
> > > > something as simple as:
> > > >
> > > > <field name="##parent"/>
> > > >
> > > > Is all that is really needed...
> > > >
> > > > But for now, you need to use ID/IDREF.
> > > >
> > > > --Keith
> > > >
> > > > Jim Otte wrote:
> > > > >
> > > > > Keith,
> > > > > Thanks again for your suggestions. I tried
> your
> > > ideas-
> > > > > and have found:
> > > > > 1. I listed the identity=id in the <class>
> > > element of
> > > > > Foo - and the parent field under Bar as
> > > <bind-xml
> > > > > node="attribute" reference="true"  /> yet I
> > > still do
> > > > > not get the expected result- just a null
> pointer
> > > when
> > > > > referencing the parent fields.
> > > > > Does the input xml have to change at all- I
> have
> > > > > changed only the mapping xml- or the
> classes?
> > > > > I need to have Bar as a child of Foo so I
> need
> > > to have
> > > > > an element for Bar:
> > > > >  <field name="bar" type="Bar">
> > > > >                         <bind-xml name="bar"
> > > > > node="element"/>
> > > > >                 </field>
> > > > >
> > > > > or else Castor complains :
> > > > > unable to find FieldDescriptor for 'bar' in
> > > > > ClassDescriptor of foo
> > > > >
> > > > > for the xml....So am I just not seeing
> something
> > > here
> > > > > or is it still a limitation for a relation
> such
> > > as
> > > > > this?
> > > > >
> > > > > Thanks for your input,
> > > > > Jim
> > > > >
> > > > > --- Keith Visco <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > >
> > > > > >
> > > > > > Jim Otte wrote:
> > > > > > >
> > > > > > > Keith,
> > > > > > >
> > > > > > > Thanks for the lead- I believe that is
> the
> > > right
> > > > > > > trail- however, when I implement the
> > > ID/IDREF
> > > > > > > attributes- I still do not get the
> reference
> > > to
> > > > > > the
> > > > > > > parent from the child - note my
> differences
> > > from
> > > > > > your
> > > > > > > example:
> > > > > > > 1. The Parent Foo has the child Bar
> class as
> > > an
> > > > > > > attribute: Foo has Bar bar; as a class
> > > member.
> > > > > >
> > > > > > Yes...that's understood...I saw the
> classes
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

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

Reply via email to