Lexi,
Thanks for your prompt response. I will have to re-design to see that
(2) is implemented. I wish the jaxb had provisions to make elements
transient using annotations without additional plugins or with
expectation that design would handle it. I know it doesn't make any
sense to have transient fields in the XSD schema, logically. But I was
trying to have things simple without extending classes in the design
and with having XSD driven data model. But I guess i have no other go
and need to implement (2).
Nevertheless, you guys are doing great job. The support is marvelous!
Thanks much again!
Cheers,
Mahesh
On Tue, Mar 10, 2009 at 4:08 PM, Aleksei Valikov <valikov_at_gmx.net> wrote:
> Hi.
>
>> The scenario I am dealing with goes like this. I have a XSD which I
>> convert it into java classes . Having the necessary data structures I
>> convert the objects of the generated classes to XML.
>>
>> Now it so happened that, I have given a element of "anytype" in the
>> XSD which then would be converted to member of class of java type
>> "Object" . Now this Object is in turn used to store complex data
>> object (data model, table model, model listener et al). I dont want
>> this member to be serialized when I convert the object to XML through
>> marshalling. This can be done in two ways:
>>
>> 1. Applying @XmlTransient annotation to the member element.
>> 2. By extending the generating class to a child class and then
>> annotating the new class. I dont want to do this since my
>> implementation is working fine but for the manual addition of
>> @XmlTransient. I want to annotate the member with @XmlTransient
>> automatically without any manual intervention. This will make my
>> application robust.
>>
>> If there is any other solution or feedback, please let me know. I
>> appreciate your time and effort on this.
>
> I have to say I don't think that mixing JAXB model data and utilities
> is a good idea, but it's up to you.
>
> Further on, if you use a schema-derived property to store utility
> objects you essentially misuse your schema therefore from the
> architecture point of you I'd say (2) is more preferrable than (1).
>
> Next, as I can say, annox/annotate plugin can not help you make your
> property transient. Yes, you can get @XmlTransient added to your
> field, BUT this will not work at the end because other @Xml
> annotations can not and will not be deleted from this field.
>
> If you want to use schema-derived field to store custom data as you
> described, I think you best option is to wrap you data in some wrapper
> class where all the properties are @XmlTransient. The wrapper class
> will be then marshalled, but your custom data not.
>
> Bye.
> /lexi
>