美文网首页
where-if中if不能识别大写AND,OR

where-if中if不能识别大写AND,OR

作者: 帮我的鸵鸟盖个章 | 来源:发表于2018-12-24 11:43 被阅读0次

mybatis报错:Caused by: org.apache.ibatis.ognl.ParseException: Encountered " <IDENT> "AND "" at line 1

报错代码:

`<select id="countByMapRt" resultType="java.lang.Long">
    SELECT COUNT(1) FROM epc_letter_notice t1
    <where>
        t1.is_delete = 0
        <if test="countryArea != null AND countryArea != ''">
            AND t1.share_place LIKE concat('%',#{countryArea},'%')
        </if>
    </where>
</select>`

产生错误的原因是if条件中AND为大写,应改为小写。大写不能识别

`<select id="countByMapRt" resultType="java.lang.Long">
    SELECT COUNT(1) FROM epc_letter_notice t1
    <where>
        t1.is_delete = 0
        <if test="countryArea != null and countryArea != ''">
            AND t1.share_place LIKE concat('%',#{countryArea},'%')
        </if>
    </where>
</select>`

相关文章

网友评论

      本文标题:where-if中if不能识别大写AND,OR

      本文链接:https://www.haomeiwen.com/subject/bcgakqtx.html