Mybatis映射器多个参数的传递
2017-12-04 本文已影响0人
Xr丶_c967
java bean 传递多个参数
List<Role> findRolesByBean(RoleParams rp)
SQL参数使用#{属性名}便可访问.
<select id="findRolesByBean" parameterType="com.xu.pojo.RoleParams" resultType="role">
select id,role_name as roleName,note from role
where role_name like concat('%', #{roleName},'%')
and note like concat('%', #{note},'%')
</select>
List <Role> findRolesByMap(<String ,Object> map)
SQL参数使用#{key}便可访问
注解传递多个参数(小于5个参数)
List<Role> finRolesByAnno(@Param("rn") String roleNmae,@Param ("note")String note);
<select id="findRoleByAnno" resultType="role">
select id,role_name as roleName,note from role
where role_name like concat('%', #{rn},'%')
and note like concat('%', #{note},'%')
</select>
注解和Java bean混合
List<Role> findByMix(@Param("rp") RoleParams rp, @Param("page") PageParams pp)
<select id="findByMix" resultType="role">
select id,role_name as roleName,note from role
where role_name like concat('%', #{rp.roleName},'%')
and note like concat('%', #{rp.note},'%')
limit #{page.start},#{page.limit}
</select>
ListfindByRb(@Param("rn") String roleName, @Param("note") String note, RowBounds rb);