XML schema types that use JAXB to generate Java primitive types do not need to be added

I am using JAXB (xjc version 2.2.4-2) to generate Java classes from XML schema XML types mapped to Java raw data types are not added:

@XmlElement(required = true)

For example, when using:

<element name="userId" type="long"/>
<element name="userName" type="string"/>

Will result in:

//no annotation added here
protected long userId;
@XmlElement(required = true)
protected String userName;

Does anyone explain why?

What does this have to do with the options you can set with xjc?

Solution

You do not need comments to display properties of Java type long, because the original value cannot be null, which is implicit Non fillable required elements of XS type: long is mapped to Java long, and optional or fillable elements are mapped to Java Lang. long (null is allowed, indicating absence or XSI: Nil, as the case may be)

Optional and nullable elements (odd, but allowed by XML schema) will be mapped to jaxbelement < long > distinguish between null jaxbelement and nil (isnil() non null jaxbelement that returns true)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>