码迷,mamicode.com
首页 > 其他好文 > 详细

ibatis 查询异常 Parameter index out of range

时间:2015-08-13 12:33:54      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

<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# 外面多了 双引号, 把双引号去掉好了

ibatis 查询异常 Parameter index out of range

标签:

原文地址:http://my.oschina.net/kelvinline/blog/491745

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!