SSM-Mybatis-动态SQL-bind
作用:通过OGNL表达式去自定义一个上下文变量,方便使用,例如:在模糊查询时,常常需要一个concat,他用%和参数相连,然而Oracle数据库则没有,Oracle数据库用连接符号|| ,这样就需要提供两种形式,但使用bind就不必要使用数据库语言,而是使用Mybatis动态SQL即可
<select id="findRole" parameterType="string" resultType="com.ssm.bean.RoleBean">
<bind name="pattern" value=" '%' + _parameter + '%' " />
selsec id ,role_name as roleName ,create_date as createDate,end_date as endDate,
end_flag as endFalg ,note FROM t_role
where role_name like #{pattern}
</select>
_parameter:是传递进来的参数,通过%连接后赋给pattern,然后在select中进行模糊查询。
Mybatis还支持多个参数使用bind元素的用法,传递多个参数没有问题