关于mybatis的哪些事!之参数越界

 Parameter index out of range (2 > number of parameters, which is 1).

 Parameter index out of range (1 > number of parameters, which is 0).

//上面两个报错或者数字换成别的,都是属于越界。
把mysql中的 #改为$就ok了
 <select id="getEncounterAngelPage" resultType="User">
        SELECT
        <include refid="userColumns"/>
        <if test="lng != null and lng != '' and lat != null and lat != ''">
            ,CEILING(SQRT(POWER(a.lng-${lng},2)+POWER(a.lat-${lat},2))*100000) AS distance
        </if>
        FROM sys_user a
        <include refid="userJoins"/>
        <if test="role != null and role.id != null and role.id != ''">
            JOIN sys_user_role ur ON ur.user_id = a.id AND ur.role_id = ${role.id}
        </if>
        <where>
            a.del_flag = #{DEL_FLAG_NORMAL}
            AND (a.user_type = '1'
            OR a.user_type = '2')
            <if test="vcEncounterSet != null">
                <if test="vcEncounterSet.ranges != null and vcEncounterSet.ranges != '' and vcEncounterSet.ranges == 2
                                                     and user != null and user != null and user.loginProvince != ''">
                    AND a.loginProvince LIKE CONCAT('%', #{user.loginProvince}, '%')
                </if>
                <if test="vcEncounterSet.ranges != null and vcEncounterSet.ranges != '' and vcEncounterSet.ranges == 3
                                                     and user != null and user != null and user.loginAddress != ''">
                    AND a.loginAddress LIKE CONCAT('%', #{user.loginAddress}, '%')
                </if>
                <if test="vcEncounterSet.identity != null and vcEncounterSet.identity != '' ">
                    <if test="vcEncounterSet.identity == 1">
                        AND (a.position ='0' OR
                        a.position = '1' OR
                        a.position = '2' OR
                        a.position= '3' )
                    </if>
                    <if test="vcEncounterSet.identity == 2">
                        AND (a.position ='0' OR
                        a.position = '1' OR
                        a.position = '2' )
                    </if>
                    <if test="vcEncounterSet.identity == 3">
                        AND (a.position ='0' OR
                        a.position = '1' )
                    </if>
                </if>
                <if test="vcEncounterSet.industry != null and vcEncounterSet.industry != '' and vcEncounterSet.industry == 1
                                                       and user != null and user != null and user.industryId != ''">
                    AND a.industry_id = ${user.industryId}
                </if>

                <if test="vcEncounterSet.sex != null and vcEncounterSet.sex != '' and vcEncounterSet.sex == 0">
                    AND a.sex = '0'
                </if>
                <if test="vcEncounterSet.sex != null and vcEncounterSet.sex != '' and vcEncounterSet.sex == 1">
                    AND a.sex = '1'
                </if>
            </if>
        </where>
        <choose>
            <when test="lng != null and lng != '' and lat != null and lat != '' and page !=null and page.orderBy != null and page.orderBy != ''">
                ORDER BY ${page.orderBy} , distance ASC
            </when>
            <otherwise>
                ORDER BY vistors DESC
            </otherwise>
        </choose>
    </select>

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值