您的位置:首页 > 其它

ibatis 查询异常 Parameter index out of range

2015-08-13 11:23 447 查看
<select id="qryUser" resultClass="java.util.HashMap"  parameterClass="java.util.HashMap" >
    SELECT userId  FROM sys_user WHERE 1=1
        <isNotEmpty property="userId">
            AND userId = "#userId#"  
        </isNotEmpty>

</select>

以上语句报错了


SqlMapClient operation; SQL []; \n

--- The error occurred while applying a parameter map. \n

--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap. \n

--- Check the parameter mapping for the 'userId' property. \n

--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException: \n

--- The error occurred while applying a parameter map. \n

--- Check the roleManagerSqlMap.qryUserAuthorityIds-InlineParameterMap. \n

--- Check the parameter mapping for the 'userId' property. \n

--- Cause: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).



查了半天,原来是因为

<isNotEmpty property="userId">
            AND userId = "#userId#"  
        </isNotEmpty>

这个#userId# 外面多了 双引号, 把双引号去掉好了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: