title: Accessing a private super class field in MyBatis
body: <p>Consider the following POJOs that will be used for holding the parameters that will be passed to a query. </p>
  
  <pre><code>public class RegionKey {
  
          private BigDecimal rgnId;
          private Country country;
  
          //setters and getters.    
  
          }
  
  public class Country {
  
          private BigDecimal cntryId;
  
          //setters and getters.   
  
          }
  
   public class Region extends RegionKey {
  
          private String rgnNm;
          private String desc;
  
          //setters and getters
  
  
      }
  
    public class Customer {
              private BigDecimal custId;
              private Region rgn;
  
          }
  </code></pre>
  
  <p>Consider the CustomerMapper interface for MyBatis </p>
  
  <pre><code>public interface CustomerMapper {
  
          int deleteByPrimaryKey(@Param("custRecord") Customer key);
      }
  </code></pre>
  
  <p>Consider a snippet from the CustomerMapper.xml file (QUery 1)</p>
  
  <pre><code> &lt;delete id="deleteByPrimaryKey"&gt;
              delete from CUSTOMER
              where CUST_ID = #{custRecord.custId,jdbcType=DECIMAL} 
              and RGN_ID =
              cast(#{custRecord.rgn.rgnId,jdbcType=CHAR} as char(10))
      &lt;/delete&gt;
  </code></pre>
  
  <p>The above query works perfectly fine. Modifying the above query with the following if-test works fine as well  (Query 2)</p>
  
  <pre><code> &lt;delete id="deleteByPrimaryKey"&gt;
                          delete from CUSTOMER
                          where CUST_ID = #{custRecord.custId,jdbcType=DECIMAL} 
                          &lt;if test="custRecord.rgn.rgnId != null"&gt;
                      and RGN_ID = cast(#{custRecord.rgn.rgnId,jdbcType=CHAR} as
                      char(10))
                          &lt;/if&gt;                   
  
                  &lt;/delete&gt;
  </code></pre>
  
  <p>Modifying the query as follows causes a runtime exception (Query 3)</p>
  
  <pre><code>&lt;delete id="deleteByPrimaryKey"&gt;
                      delete from CUSTOMER
                      where CUST_ID = #{custRecord.custId,jdbcType=DECIMAL} 
                      &lt;if test="custRecord.rgn.country.cntryId != null"&gt;
                  and CNTRY_ID =
                  cast(#{custRecord.rgn.country.cntryId,jdbcType=CHAR} as
                  char(10))
                      &lt;/if&gt;
  
  
  
              &lt;/delete&gt;
  </code></pre>
  
  <p>I get a org.apache.ibatis.ognl.NoSuchPropertyException at runtime for query number 3. I am unable to understand why this happens. If I can access the rgnId field from custRecord.rgn in query 2, I should technically be able to access the cntryId field from custRecord.rgn.country in query number 3. </p>