mybatis之Parameter 'gradeName' not found. Available parameters are [gradeConfigBean, param1

2023-10-12 14:41:42 浏览数 (2)

Parameter ‘gradeName’ not found. Available parameters are [gradeConfigBean, param1

这个异常来自dao层

GradeConfigBean 是个实例对象

代码语言:javascript复制
public  List<GradeConfigBean> findList(@Param("gradeConfigBean") GradeConfigBean gradeConfigBean);

对应的xml文件中的sql

代码语言:javascript复制
<select id="findList" resultType="com.xwtec.gradeConfig.entity.GradeConfigBean"
		parameterType="com.xwtec.gradeConfig.entity.GradeConfigBean">
		SELECT	gradeId,
				gradeName,
				eventId,
				eventName,
				groupLimitCount,
				maxCount,
				minCount,
				remark,
				usable,
				GRADEALIAS as gradeallas,
				gradeSort
		FROM	 T_ORIENT_GRADEINFO
		WHERE	1=1
		<if test="gradeName != '' and gradeName != null">
			AND gradeName LIKE 
				<if test="dbName == 'oracle'">'%'||#{gradeName}||'%'</if>
				<if test="dbName == 'mysql'">CONCAT('%', #{gradeName}, '%')</if>
		</if>
		
		<if test="eventName != '' and eventName != null">
			AND eventName = #{eventName}
		</if>

		<if test="usable != '' and usable != null">
			AND usable = #{usable}
		</if>
		ORDER BY usable ,	gradeSort
	</select>

显然在xml中找不到gradeName这个变量 因为它以为传一个参数 但在xml中多个参数 而且名字不对应 所以报错 解法方法: 把@Param("gradeConfigBean")去掉就完事了

参考博客: https://www.cnblogs.com/future-liu1121/p/7768750.html

0 人点赞