查询数据库报错如下:
Cause: org.apache.ibatis.type.TypeException: Error setting non null for parameter #7 with JdbcType
定位到报错 SQL处:
<!-- 公用查询排序条件:单票 -->
<sql id="Common_Order_Condition">
<if test="orderField != null and orderField != '' and orderType != null and (runInHole == null or runInHole == false)">
/*order by concat('t.', #{orderField})*/
order by #{orderField}
<include refid="Order_Type_Column"/>
</if>
</sql>
乍一看没啥问题,运行就是报错,无用代码也已经注释了,最后找了各种方法才发现,注释的格式不对,在 if 语句中切忌不能使用文档注释格式
,要使用单行或多行格式注释:
<!-- 公用查询排序条件:单票 -->
<sql id="Common_Order_Condition">
<if test="orderField != null and orderField != '' and orderType != null and (runInHole == null or runInHole == false)">
<!-- order by concat('t.', #{orderField}) -->
order by #{orderField}
<include refid="Order_Type_Column"/>
</if>
</sql>
这样就可以了,xml 的坑,又踩了一遍。