title: Serialize Object To XML in java ignores some variable fields of my object
body: <p>I am trying to serialize my object to an xml file, the problem is that some of the instance variables of this object are not written in the xml file. 
  I don't know why are they ignored and how to get the serialize method to write every variable in the xml file.
  I have noticed that when I set (using the setter) some of these variables are more likely to be written in xml file.</p>
  
  <p>What I am asking:</p>
  
  <p>1- I want to know why some of the instance variables are not written inside the XML file when their Object is serialized.</p>
  
  <p>2- How to enforce all instance variables of my object to be written into the file, when I serialize that object to XML.</p>
  
  <hr>
  
  <p>my class </p>
  
  <pre><code>package DBMS;
  
  import JDBC.ResultSetMetaData;
  
  public class Column {
  
  private String colName= "";
  private String type="";
  private boolean isPrimary= false;
  private boolean isAutoIncrement= false;
  private int NullableState = ResultSetMetaData.columnNullableUnknown;
  private boolean isReadOnly= false;
  private boolean isSearchable= true;
  private String tableName= "unknown";
  private int incrementNextValue = 1;
  
  
  public Column() {
      // TODO Auto-generated constructor stub
  
  }
  
  public Column(String n, String t) {
  
      colName = n;
      type=t;
  }
  
  
  public String getTableName() {
      return tableName;
  }
  
  public void setTableName(String s) {
      tableName = s;
  }
  
  public String getColName() {
      // TODO Auto-generated method stub
      return colName;
  }
  
  public void setColName(String s) {
      // TODO Auto-generated method stub
      colName = s;
  }
  
  public String getType() {
      return type;
  }
  
  public void setType(String type) {
      this.type = type;
  }
  
  public boolean isPrimary() {
      return isPrimary;
  }
  
  public void setPrimary(boolean isPrimary) {
      this.isPrimary = isPrimary;
  }
  
  public boolean isAutoIncrement() {
      return isAutoIncrement;
  }
  
  public void setAutoIncrement(boolean isAutoIncrement) {
      this.isAutoIncrement = isAutoIncrement;
  }
  
  public int getNullableState() {
      return NullableState;
  }
  
  public void setNullable(int Nullable) {
      this.NullableState = Nullable;
  }
  
  public boolean isReadOnly() {
      return isReadOnly;
  }
  
  public void setReadOnly(boolean isReadOnly) {
      this.isReadOnly = isReadOnly;
  }
  
  public boolean isSearchable() {
      return isSearchable;
  }
  
  public void setSearchable(boolean isSearchable) {
      this.isSearchable = isSearchable;
  }
  
  public int getIncrementNextValue() {
      return incrementNextValue;
  }
  
  public void setIncrementNextValue(int incrementNextValue) {
      this.incrementNextValue = incrementNextValue;
  }
  
  }
  </code></pre>
  
  <p>method serialize </p>
  
  <pre><code>public  void serializeObjectToXML(String xmlFileLocation, ArrayList&lt;Column&gt; objectToSerialize) throws Exception {
  
      FileOutputStream os = new FileOutputStream(xmlFileLocation);
      XMLEncoder encoder = new XMLEncoder(os);
      encoder.writeObject(objectToSerialize);
      encoder.close();
      os.close();
  }
  </code></pre>
  
  <p>sample xml output</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   -&lt;java class="java.beans.XMLDecoder" version="1.7.0_07"&gt;
   -&lt;object class="java.util.ArrayList"&gt;
   -&lt;void method="add"&gt; 
   -&lt;object class="DBMS.Column"&gt;
   -&lt;void property="autoIncrement"&gt; &lt;boolean&gt;true&lt;/boolean&gt; &lt;/void&gt; 
   -&lt;void property="colName"&gt; &lt;string&gt;ID&lt;/string&gt; &lt;/void&gt; 
   -&lt;void property="readOnly"&gt; &lt;boolean&gt;true&lt;/boolean&gt; &lt;/void&gt; 
   -&lt;void property="tableName"&gt; &lt;string&gt;testSerialize&lt;/string&gt; &lt;/void&gt; 
   -&lt;void property="type"&gt; &lt;string&gt;int&lt;/string&gt; &lt;/void&gt; &lt;/object&gt; &lt;/void&gt;
   -&lt;void method="add"&gt;
   -&lt;object class="DBMS.Column"&gt;
   -&lt;void property="colName"&gt; &lt;string&gt;Name&lt;/string&gt; &lt;/void&gt; 
   -&lt;void property="primary"&gt; &lt;boolean&gt;true&lt;/boolean&gt; &lt;/void&gt;
   -&lt;void property="tableName"&gt; &lt;string&gt;testSerialize&lt;/string&gt; &lt;/void&gt;
   -&lt;void property="type"&gt; &lt;string&gt;string&lt;/string&gt; &lt;/void&gt; &lt;/object&gt; &lt;/void&gt; -&lt;void    method="add"&gt; 
   -&lt;object class="DBMS.Column"&gt; 
   -&lt;void property="colName"&gt; &lt;string&gt;info&lt;/string&gt; &lt;/void&gt;
   -&lt;void property="tableName"&gt; &lt;string&gt;testSerialize&lt;/string&gt; &lt;/void&gt; -&lt;void property="type"&gt; &lt;string&gt;string&lt;/string&gt; &lt;/void&gt; &lt;/object&gt; &lt;/void&gt; 
   -&lt;void method="add"&gt;
   -&lt;object class="DBMS.Column"&gt;
   -&lt;void property="colName"&gt; &lt;string&gt;data&lt;/string&gt; &lt;/void&gt;
   -&lt;void property="tableName"&gt; &lt;string&gt;testSerialize&lt;/string&gt; &lt;/void&gt;
   -&lt;void property="type"&gt; &lt;string&gt;string&lt;/string&gt; &lt;/void&gt; &lt;/object&gt; &lt;/void&gt; &lt;/object&gt; &lt;/java&gt;
  </code></pre>