ibatis 查詢異常 Parameter index out of range

<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>

以上語句報錯了
java

SqlMapClient operation; SQL [];   \nsql

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

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

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

--- 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:   \nio

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

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

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

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


查了半天,原來是由於

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

這個#userId# 外面多了 雙引號, 把雙引號去掉好了

相關文章
相關標籤/搜索