title: Proper way to access an association of a newly inserted object in with MyBatis
body: <p>I'm using MyBatis 3.4.6.</p>
  <p>Let's say I have a POJO with an association, i.e.</p>
  <h3>Person</h3>
  <ul>
  <li>PersonID</li>
  <li>CompanyID</li>
  <li>PersonName</li>
  <li>Company (Association to <code>Company</code> class)</li>
  </ul>
  <h3>Company</h3>
  <ul>
  <li>CompanyID</li>
  <li>CompanyName</li>
  </ul>
  <p>And, let's say I already have a DB full of <code>Company</code> records, but I'd like to add a new <code>Person</code> to <code>Company</code> with an ID of 1 and then subsequently retrieve my association.</p>
  <pre><code>Person p = new Person();
  p.setPersonName(&quot;Ryan&quot;);
  p.setCompanyID(1);
  
  personMapper.insert(p);
  
  Company c = p.getCompany() // I'd like to retrieve the association here
  </code></pre>
  <p>I know that I can just re-query my person and the association will be loaded, but is that the standard / acceptable way to accomplish such things?</p>
  <p>I.e.</p>
  <pre><code>Person p = new Person();
  p.setPersonName(&quot;Ryan&quot;);
  p.setCompanyID(1);
  
  personMapper.insert(p);
  
  // In the below code, the &quot;PersonID&quot; **did** refresh from the DB after insert 
  // so I have access to it, but my associations do not initialize after insert, 
  /// so I have to re-query the DB to get a new Person object with my Company association
  p = personMappper.get(p.getPersonID()); 
  
  Company c = p.getCompany() // This will return as expected
  </code></pre>