That's correct, except that I would be perfectly happy (ecstatic really)
to have the class attribute be set to the base class name as well. 

R

-----Original Message-----
From: Jay Goldman [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 15, 2004 7:54 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] [XML] Inheritance and mapping the base class.



Using transient and/or setting the auto-complete will eliminate any
unwanted properties; however, won't the top level element still be
'something' or 'some-other-thing'?. I understood Rick's question as
wanting a way to marshall a 'Something' and get xml that has a top level
element of 'base' without a 'class' attribute. 
Jay

-----Original Message-----
From: Benoit Maisonny [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 14, 2004 3:23 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] [XML] Inheritance and mapping the base class.



You can tell Castor to marshall only what you want from your classes.
One way is by setting the transient attribute to true on the field 
element in your mapping. Another way is by setting the auto-complete 
attribute to false on the class element and specifying each field that 
you want to marshall. I guess you can do it in yet another way using 
FieldHandlers. Read the documentation to decide what's best for you.

Benoit


Rick Ross wrote:

> Sure, I recognize that java is behaving as expected.  But surely this 
> is not the first time this has come up.
> 
> I would have imagined many people want to do this, and for us, we'd
> rather avoid clone/copy because we expect to do it a lot.
> 
> Thanks.
> 
> R
> 
> -----Original Message----- From: Jay Goldman 
> [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 14, 2004 5:46 AM
>  To: [EMAIL PROTECTED] Subject: Re: [castor-user] [XML] 
> Inheritance and mapping the base class.
> 
> 
> Since java objects (unlike c++ objects) do not change their type when

> they are 'cast' the castor behavior is correct. In fact, the cast is  
> essentially meaningless - at runtime you have a Something or a 
> SomeOtherThing not simply a Base. You could obviously create a Base 
> instance using the object you have (via clone or copy constructor on
> Base) and then marshall this instance.
> 
> Jay
> 
> -----Original Message----- From: Rick Ross [mailto:[EMAIL PROTECTED]

> Sent: Wednesday, July 14, 2004 1:11 AM
> To: [EMAIL PROTECTED] Subject: [castor-user] [XML] Inheritance 
> and mapping the base class.
> 
> 
> 
> Hi.  I have some base classes I use for a group of classes. Something 
> like:
> 
> public class Base { // a bunch of bean style getters and setters. }
> 
> public class Something extends Base { // different getters and setters

> }
> 
> public class SomeOtherThing extends Base { // you get the picture...
> }
> 
> When objects are instantiated, they are always instantiated as 
> Something or SomeOtherThing objects.  When I go to marshall them, I 
> always cast them into Base objects because that is all I want 
> marshalled. However, I always get the fields from Something and 
> SomeOtherThing.
> 
> In fact, in the xml output, the class attribute is always the fully
> qualified class name of the instantiated class, not the base class.
> 
> I have tried a mapping and using the "extends" attribute, but that did

> not work either.  In that case, the output had something like 
> some-other-thing as the class name, which I seem to recall is a castor

> name mangling convention.
> 
> I thought I could do this in the mapping :
> 
> <class name="SomeOtherThing" extends="Base" /> <class name="Base">
> ... all of my mapping for the base class fields here. </class>
> 
> Can anyone offer a bit of insight?   Am I just missing the concept or
>  missing a setting?
> 
> Thanks
> 
> Rick
> 
> 
> 
> 
> ----------------------------------------------------------------------
> --
> 
> 
> ----------------------------------------------------------- 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

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

Reply via email to