title: In JAXB, Why does some elements generate with the Long datatype, and others with the long datatype when minOccurs is defined?
body: <p>I found something pretty peculiar, and probably insignificant. When you define in an XSD an Element with the type <code>xs:long</code>, and you don't set <code>minOccurs="0"</code>, and you run it through JAXB, the resulting element is of type <code>long</code>. However, when you do set <code>minOccurs="0"</code> in the XSD element, the resulting element is of type <code>Long</code>. Notice the difference between the <code>long</code> and <code>Long</code> DataType</p>
  
  <p>Now, with the work I do, I do some <code>if (thisVariable == null)</code> tests, and naturally, <code>long</code> cannot be null. <code>Long</code> can.</p>
  
  <p>*<strong><em>What I would like to know, is this a bug in JAXB which causes this difference between the resulting variables, or is it intended for these resulting variables to come out the way they do? *</em></strong></p>
  
  <p>Here was the files I used to test with:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;
  &lt;xs:schema id="ReportRequestWrapper" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"&gt;
    &lt;xs:element name="ReportRequestWrapper"&gt;
      &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="queryId" type="xs:long" minOccurs="0" /&gt;
          &lt;xs:element name="reportId" type="xs:long" minOccurs="0" /&gt;
        &lt;/xs:sequence&gt;
      &lt;/xs:complexType&gt;
    &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p><code>queryId</code> and <code>reportId</code> came out as follows:</p>
  
  <pre><code>public class ReportRequestWrapper {
  
      protected Long queryId;
      protected Long reportId;
  </code></pre>
  
  <p>If I omitted the MinOccurs="0", </p>
  
  <pre><code>        &lt;xs:element name="queryId" type="xs:long"  /&gt;
          &lt;xs:element name="reportId" type="xs:long"  /&gt;
  </code></pre>
  
  <p>The result turned into</p>
  
  <pre><code>public class ReportRequestWrapper {
  
      protected long queryId;
      protected long reportId;
  </code></pre>
  
  <p>I just found this pretty curious and wanted some more information on this one.</p>