Mybatis映射器多个参数的传递

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容