美文网首页Java
Mybatis映射器多个参数的传递

Mybatis映射器多个参数的传递

作者: Xr丶_c967 | 来源:发表于2017-12-04 12:30 被阅读0次

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);

相关文章

网友评论

    本文标题:Mybatis映射器多个参数的传递

    本文链接:https://www.haomeiwen.com/subject/hwfbvxtx.html