Hi Keith,
Which version of Castor are you using?
If you are not using the CVS version, please try that version instead,
this should have already been fixed for the problem you are specifying.
If you are already using this version, I will look into it.
Thanks,
--Keith
Keith Chew wrote:
>
> Hi Keith
>
> I get the following exception:
>
> org.exolab.castor.mapping.MappingException: The method addDetail in class
> myapp.Product accepting/returning object of type class java.util.Vector was
> not found
>
> Any thoughts?
> Keith C
>
> > -----Original Message-----
> > From: Keith Visco [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, 12 October 2001 6:06 a.m.
> > To: [EMAIL PROTECTED]
> > Subject: Re: [castor-dev] 1:n and xml
> >
> >
> >
> >
> > Hi Keith,
> >
> > In your first post you said that you wanted to use the "addDetails"
> > method instead of the setDetails method.
> >
> > So...the solution is to take the field mapping and alter it as follows:
> >
> >
> > <field name="details" type="myapp.ProductDetail" required="true"
> > collection="vector"
> > set-method="addDetail"
> > get-method="getDetails">
> > <sql many-key="prod_id"/>
> > <xml name="detail" node="element" />
> > </field>
> >
> > --Keith
> >
> > Keith Chew SL wrote:
> > >
> > > Hi Keith
> > >
> > > The mapping file is actually like this:
> > >
> > > <field name="details" type="myapp.ProductDetail" required="true"
> > > collection="vector">
> > > <sql many-key="prod_id"/>
> > > <xml name="detail" node="element" />
> > > </field>
> > >
> > > And I do have a setDetails() as follow:
> > >
> > > public void setDetails (Vector details) {
> > > Enumeration enum = details.elements();
> > > while (enum.hasMoreElements()) {
> > > ProductDetail productDetail = (ProductDetail) enum.nextElement();
> > > productDetail.setProduct (this);
> > > }
> > > this.details = details;
> > > }
> > >
> > > But this method is never called by Castor. In the meantime, I
> > have solved
> > > the problem by having this method:
> > >
> > > public void resetDetailsReference() {
> > > setDetails (getDetails());
> > > }
> > >
> > > So, after unmarshalling, I call this method:
> > >
> > > Product product = Unmarshaler.unmarshal ( ... );
> > > product.resetDetailsReference();
> > >
> > > It will now loop through all the elements and set the reference.
> > >
> > > If there is another solution, I'd be keen to know. Thanks Keith
> > > Keith C
> > >
> > > > -----Original Message-----
> > > > From: Keith Visco [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, 11 October 2001 8:42 p.m.
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Re: [castor-dev] 1:n and xml
> > > >
> > > >
> > > >
> > > > Hi Keith,
> > > >
> > > > In your mapping file just use:
> > > >
> > > > <class ...>
> > > >
> > > > ...
> > > > <field name="detail" set-method="addDetail" ...>
> > > > ...
> > > > </field>
> > > > ...
> > > >
> > > > </class>
> > > >
> > > > Hope that helps,
> > > >
> > > > --Keith
> > > >
> > > > Keith Chew wrote:
> > > > >
> > > > > Hi
> > > > >
> > > > > I have a 1:n relationship, similar to the Product & ProductDetail in
> > > > > Castor's example. When I try to output to an XML (using
> > > > Marshaler) it does
> > > > > it correctly. When reading from the XML (using Unmarshaler)
> > it reads it
> > > > > correctly too (well almost).
> > > > >
> > > > > Here is the problem:
> > > > >
> > > > > public void addDetail( ProductDetail detail )
> > > > > {
> > > > > _details.add( detail );
> > > > > detail.setProduct( this );
> > > > > }
> > > > >
> > > > > When adding a ProductDetail in Product, this method is called
> > > > so that the
> > > > > reference is set. But the Unmarshaler does not seem to call
> > > > this method when
> > > > > constructing the Product class. Do I need a Class Descriptor or
> > > > some sort to
> > > > > make the Unmarshaler work correctly?
> > > > >
> > > > > Regards
> > > > > Keith C
> > > > >
> > > > > -----------------------------------------------------------
> > > > > If you wish to unsubscribe from this mailing, send mail to
> > > > > [EMAIL PROTECTED] with a subject of:
> > > > > unsubscribe castor-dev
> > > >
> > > > -----------------------------------------------------------
> > > > If you wish to unsubscribe from this mailing, send mail to
> > > > [EMAIL PROTECTED] with a subject of:
> > > > unsubscribe castor-dev
> > > >
> > > >
> > > >
> > >
> > > -----------------------------------------------------------
> > > If you wish to unsubscribe from this mailing, send mail to
> > > [EMAIL PROTECTED] with a subject of:
> > > unsubscribe castor-dev
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-dev
> >
> >
> >
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev