users@jaxb.java.net

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

From: Colin Fleming <colin.mailinglist_at_gmail.com>
Date: Wed, 10 Dec 2008 19:39:01 +0100

Hi Tomasz,

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). 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.

Cheers,
Colin


2008/12/4 Tomasz Toczyski <guf_at_kajak.org.pl>

> > you can use JAXB customizations to generate any type from any element....
> >
> > like this example:
> > http://java.sun.com/javaee/5/docs/tutorial/doc/bnbbf.html#bnbci
>
> It does not solve my problem. If I declare minOccurs="0" Jaxb2 maps such
> element to Integer type. But I want primitive int type.
>
> Jaxb1 generated primitive int type even if I declare minOccurs="0". If
> there were no such an element in my xml document a getter related to this
> element returned 0 value. Can I force Jaxb2 to operate like Jaxb1 ?
>
> -tt.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>