title: Using BeanUtils.copyProperties from a Mybatis created object to a Spring Bean, the properties are null in the Spring bean. Why?
body: <p>The problem I am encountering is that I have a class that looks something like this</p>
  
  <pre><code>@Component
  @RequestScope
  public class TableModel{
  
      private Integer tableField1;
  
      ...
      //other properties, getters and setters here
  
  }
  </code></pre>
  
  <p>Mybatis returns results from queries mapped to this object, and I wish to copy the result from this object to my Spring bean in a different class, like so:</p>
  
  <pre><code>public class MyClass {
  
        TableModel model
  
        @Autowired
        MyClass(TableModel model) {
             this.model = model;
             //...
        }
  
        //some code
  
        TableModel result = MyMapperInterface.selectFromTable();
        //Here, result.tableField1 is not 0 or null
  
        BeanUtils.copyProperties(result, model);
  
        //After copyProperties(), model.tableField1 is still null
        //...     
  
  }
  </code></pre>
  
  <p>However, after the <code>BeanUtils.copyProperties()</code> call, the properties in <code>model</code> are still null. I double checked, and I am <strong>not</strong> using the Apache Commons version of copyProperties, I am using the Spring version of BeanUtils. What is the issue?</p>