I simplifed my problem as following code.
Mapper Interface looks like:
@Mapper
public interface TestMapper {
public Integer countTable(@Param("tValue1") Integer tValue1);
public Integer maxTable(@Param("tValue2") Integer tValue2);
}
Mapper Xml looks like:
<sql id="sql_where">
<where>
<if test="tValue1 != null">tValue1 = #{tValue1}</if>
<if test="tValue2 != null">AND tValue2 = #{tValue2}</if>
<where>
</sql>
<select id="countTable" resultType="Integer">
SELECT COUNT(*) FROM TestTable
<include refId="sql_where"/>
</select>
<select id="maxTable" resultType="Integer">
SELECT MAX(*) FROM TestTable
<include refId="sql_where"/>
</select>
when countTable or maxTable method is called, BindingException occurs. Due to one of parameter is not found.
How can I check the parameter exists in XML? I could've insert all params to method, but I don't want programmers to be confused (they're not going to be used)