When creating Java beans from XSD with XJC, I need to map xs:integer to Integer , not BigInteger . I added the javaType tag to my JAXB configuration file (as said in many answers from this site), and it worked fine.
But in the generated code, I noticed that the @XmlElement tag now has a type=String.class .
So now I wonder why String ?
Is it because parsing and printing methods are being converted from / to string objects?
I tried using xjc:javaType instead of jaxb:javaType , which allowed jaxb:javaType to replace the generated Adapter1<String, Integer> with the custom MyAdapter<BigInteger, Integer> , but it happened the same way.
If this is normal XJC behavior, is it possible to configure it to generate code without this parameter or with a value other than String ?
Please note that everything is working fine, but I would like to understand.
I also use Enunciate to document my API and it seems to confuse this type thing (but this is probably an error in Enunciate).
I am using JAXB RI 2.2.6, and here are some code snippets to illustrate my question:
bindings.xjb
<jaxb:bindings version="2.0" ...> <jaxb:globalBindings> <jaxb:javaType name="java.lang.Integer" xmlType="xs:integer" parseMethod="..." printMethod="..." /> </jaxb:globalBindings> </jaxb:bindings>
Field Definition in XSD
<xs:complexType name="MyType"> <xs:sequence> <xs:element name="myField" type="xs:integer" /> </xs:sequence> </xs:complexType>
Java generated field
@XmlElement(namespace = "...", required = true, type = String.class) @XmlJavaTypeAdapter(Adapter1.class) @XmlSchemaType(name = "integer") protected Integer myField;