Mybatis动态SQL单一基础类型参数如何使用用if标签

编程

if判断时不能直接用参数名,要用`_parameter`

```

List<AlarmCountVo> getAlarmCountVos(Integer companyId);

```

则对应的mapper写法

```

<select id="getAlarmCountVos" parameterType="java.lang.Integer" resultMap="alarmCountVoMap">

select a.`type`, count(a.id) as count from prod_alarm a

left join prod_device d on a.device_id=d.id

<where>

a.status = 0

<if test="_parameter != null">

and d.`company_id` = #{companyId}

</if>

</where>

group by a.`type`

</select>

```

以上是 Mybatis动态SQL单一基础类型参数如何使用用if标签 的全部内容, 来源链接: utcz.com/z/511209.html

回到顶部