欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

在Mybatis传值想后台传条件值问题

程序员文章站 2022-07-15 13:24:53
...

今天遇到一个问题一直报错,我需要向后台传递要查询的条件。

<!-- 根据分组id查询全部信号灯设备 -->
	<select id="selectLightByGroupid" resultMap="DevTrafficLightVo">
		SELECT
		<!-- rg_rgl_group_info.ID AS ID, -->
		rg_rgl_group_info.NAME AS NAME,
		rg_dev_traffic_light.DEV_NAME AS
		DEV_NAME,
		rg_dev_traffic_light.id,
		( SELECT camera_id FROM
		rg_light_camera_link WHERE rg_dev_traffic_light.ID =
		rg_light_camera_link.TRAFFIC_LIGHT_ID )
		AS cameraId,
		rg_cross.CROSS_NAME AS crossName
		FROM
		(
		(
		rg_cross
		JOIN
		rg_dev_traffic_light
		)
		JOIN rg_rgl_group_info
		)
		WHERE
		(
		
		rg_dev_traffic_light.CROSS_ID = rg_cross.ID
		
		AND 
		rg_cross.GROUP_ID =
		rg_rgl_group_info.ID
		
		<if test="groupid != null">
			AND rg_rgl_group_info.ID = #{groupid}
		</if>
		
		)
	</select>

开始时,是直接传递<if>标签中的数据,但是一直报错

There is no getter for property named 'groupid' in 'class java.lang.Long'

后来从网上查到,需要将if标签中的数据

<if test="_parameter != null">
	AND rg_rgl_group_info.ID = #{groupid}
</if>

参考我之前有篇文章。

相关标签: _parameter