title: Mybatis If statements using include properties
body: <p>I'm trying to create a generic SQL include in Mybatis that will apply a comparator given a particular value. The idea is to reuse this sql code snippet across several mappers. The issue I'm having is when using string substitution in the if statement inside of my include.</p>
  
  <p>Currently the xml looks like this: </p>
  
  <pre><code>&lt;select id="get" parameterType="ServiceModelQueryHelper" resultMap="ServiceRecordMap"&gt;
      SELECT * from service
      &lt;if test="name.isApplicable()"&gt;
          WHERE service.name
          &lt;include refid=comparatorMapper&gt;
              &lt;property name="comparator" value="${name.comparator}"/&gt;
              &lt;property name="value" value="${name.value}"/&gt;
          &lt;/include&gt;
      &lt;/if&gt;
  &lt;/select&gt;
  &lt;sql id="comparatorMapper"&gt;
      &lt;if test="${comparator} == 'EQUALS'"&gt;
          = ${value}
      &lt;/if&gt;
      &lt;if test="${comparator} == 'CONTAINS'"&gt;
          ~ ${value}
      &lt;/if&gt;
  &lt;/sql&gt;
  </code></pre>
  
  <p>When using the ${comparator} inside of the test the OGNL expression is evaluated before the string substitution occures causing a ParseException because $ is not a valid first character.</p>
  
  <p>Is there a way to reference a property of an sql snippet inside of an OGNL expression?</p>