title: Marshal an iterator of object using JAXB
body: <p>I having problem marshaling an iterator of objects using JAXB</p>
  
  <p><strong>User class:</strong></p>
  
  <pre><code>@XmlRootElement(name="User")
  public class User{
      private Long id;
      private String name,mailid;
      private boolean isActive;
      public Long getId() {
  
          return id;
      }
      public void setId(Long id) {
          this.id = id;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getMailid() {
          return mailid;
      }
      public void setMailid(String mailid) {
          this.mailid = mailid;
      }
      public boolean isActive() {
          return isActive;
      }
      public void setActive(boolean isActive) {
          this.isActive = isActive;
      }
  
  }
  </code></pre>
  
  <p><strong>Function which return's an Iterator of User</strong> :</p>
  
  <pre><code>public static Iterator&lt;User&gt; mapDoToUserObject(DataObject dao){
  
      final Iterator&lt;Row&gt; userRow = getRow(dao,USER.TABLE);
  
  
      return new Iterator&lt;User&gt;() {
          @Override
          public boolean hasNext() {
              return userRow.hasNext();
          }
  
          @Override
          public User next() {
              Row user = userRow.next();
              User user = new User();
              user.setId((Long)user.get(USER.USER_ID));
              user.setName((String) user.get(USER.FIRST_NAME));
              user.setMailid((String)user.get(USER.EMAIL_ID));
              return user;
          }
  
          @Override
          public void remove() {
              throw new UnsupportedOperationException("Remove not supported");
  
          }
      };  
  }
  </code></pre>
  
  <p>How to marshal an iterator of Users using JAXB ?</p>