title: MyBatis Dynamic SQL using Longs
body: <p>I'm doing a migration from iBatis to myBatis and during the conversion, I had query that used to work, but now it does not.  I've been banging my head against a wall for longer than I'd like to admit trying to get this working.  </p>
  
  <p>The query in iBatis was:</p>
  
  <pre><code>&lt;select id="countForACol" parameterClass="java.lang.Long" resultClass="java.lang.Long"&gt;
      SELECT
          COUNT(1) AS 'val'
      FROM
          someTable WITH(NOLOCK)
      &lt;isParameterPresent prepend="WHERE"&gt;
          someCol = #colId#
      &lt;/isParameterPresent&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Now, I've translated it to a query that looks like this:</p>
  
  <pre><code>&lt;select id="selectTotalRegionCountForGbs" parameterType="Long" resultType="java.lang.Long"&gt;
      SELECT
          COUNT(1) AS 'val'
      FROM
          someTable WITH(NOLOCK)
      &lt;where&gt;
          &lt;if test="colId != null"&gt;
              someCol = #{colId}
          &lt;/if&gt;
      &lt;/where&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>This, however, doesn't work.  The error I receive when trying to run it is:</p>
  
  <pre><code>org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'colId' in 'class java.lang.Long'
  Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'colId' in 'class java.lang.Long'
  </code></pre>
  
  <p>I can tell that it is trying to treat the Long object like an object that has a getter called 'getColId' which predictably doesn't exist but I don't know how to signal to MyBatis to use the value of the Long.</p>
  
  <p>How do I get this to work?</p>