users@jaxb.java.net

Re: primitive types (int, double etc.) instead of class types

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Wed, 10 Dec 2008 22:40:12 +0100

Hi.

> The problem is that if JAXB generates a primitive int in that case (with
> minOccurs=0) then you have no way to tell if the document actually contained
> that element/attribute (i.e. if your field contains 0, you have no way of
> telling if the field was not supplied, or if it was supplied and had the
> value 0).

You can generate "isSet" method for such cases.

> I'm not aware of any way to make JAXB2 work the way you want,
> although there may be one. You can might be able to use a global
> customisation which would not require touching your schemas.

Please see the globalBindings/_at_optionalProperty customization,
sections 5.5.1 and 5.5.4 in the spec.

Bye.
/lexi