mybatis 查询判空

<sql id="selectCondition">
        <if test="storeCode != null and storeCode != '' ">
            AND store_code = #{storeCode}
        </if>
        <if test="saleDates != null and saleDates.size() > 0 ">
            AND sale_date in
            <foreach collection="saleDates" open="(" close=")" separator="," item="saleDate">
                #{saleDate}
            </foreach>
        </if>
    </sql>


    <select id="selectBaseEvaluationData" resultMap="storeMainSkuEvaluationResultMap">
        SELECT
        <include refid="selectField"/>
        FROM ${tableName}
        <where>
            <include refid="selectCondition"/>
        </where>
    </select>


list集合的查找数据的 sql,当判断 list != ‘ ’ 时,会引起集合与Stirng类型的比较,报错invalid comparison: java.util.ArrayList and java.lang.String
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页