流程

1,mapper 接口文件使用 @param 注解(一个参数就不用使用注解,多个参数要么使用注解,要么使用数组的方式取值)

2,mapper xml 文件使用

mapper 接口文件传参

public interface AccountMapper {
List<Account> selectBySearch(@Param("record") Account record, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("companyName") String companyName);
}

mapper xml 文件使用参数

传入的参数不止一个,就不要指定参数类型

<select id="selectBySearch" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from main_account
where 1 = 1
<!-- 使用参数 1 (是个对象) -->
<if test="record.email != null">
and email = #{record.email}
</if>
<!-- 使用参数 2 -->
<if test="startDate != null">
and create_date &gt; str_to_date(concat('', #{startDate}),'%Y-%m-%d %H %i %s')
</if>
<!-- 使用参数 3 -->
<if test="endDate != null">
and create_date &lt; str_to_date(concat('', #{endDate}),'%Y-%m-%d %H %i %s')
</if>
<!-- 使用参数 4 -->
<if test="companyName != null">
and (full_name like "%"#{companyName}"%" or short_name like "%"#{companyName}"%")
</if>
</select>

Mybatis 同时传入多个参数和对象的更多相关文章

  1. Mybatis 接口传入多个参数 xml怎么接收

    mybatis 在接口上传入多个参数 1.如果传入的参数类型一样. Map<String, String> queryDkpayBindBankCidByOriBindAndBankCid ...

  2. MyBatis如何传入多个参数

    一.单个参数 mapper public List<Test> getTestList(String id); xml <select id = "getTestList& ...

  3. mybatis如何传入一个list参数

    <!-- 7.2 foreach(循环List<String>参数) - 作为where中in的条件 -->  <select id="getStudentLi ...

  4. jQuery form插件的使用--ajaxForm()和ajaxSubmit()的可选参数项对象

    一.前提说明 Form Plugin API 里提供了很多有用的方法可以让你轻松的处理表单里的数据和表单的提交过程. 测试环境:部署到Tomcat中的web项目. 二.简单介绍 本文演示的是:jQue ...

  5. mybatis从dao传入多个参数到sqlmap时dao中要使用map或实例对象(如:user)作为参数传入, 否则报错找不到属性getter方法

    23:37 2015-07-02 注意1. 使用mybaits的resultMap查询时, 如果想传入多个参数(比如where 1=1动态多条件查询时)sqlmap文件中对应的方法中, selectL ...

  6. Mybatis的parameterType传入多个参数

    如果查询的条件有多个的时候,mybatis有三种传入方式: 1.通过注解传入 例如: public interface Mapper(){ public User login(@Param(" ...

  7. (转载)mybatis中传入参数是list或map

    原文地址:http://blog.csdn.net/aya19880214/article/details/41961235 foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集 ...

  8. Mybatis:传入参数方式以及#{}与${}的区别

    一.在MyBatis的select.insert.update.delete这些元素中都提到了parameterType这个属性.MyBatis现在可以使用的parameterType有基本数据类型和 ...

  9. 每日一记-mybatis碰到的疑惑:String类型可以传入多个参数吗

    碰到一个觉得很疑惑的问题,Mybatis的parameterType为String类型的时候,能够接收多个参数的吗? 背景 初学Mybatis的时候,看的教程和书籍上都是在说基本的数据类型如:int. ...

随机推荐

  1. 网管到CEO的10年逆袭之路

    把我个人近一年来讲的技术人员如何成长的鸡汤课整理了出来,送给大家<网管到CEO的10年逆袭之路>

  2. springcloud开篇

    微服务作为现在的常用架构,已经到了不学不行的地步.君不见spring官网https://spring.io/已经将springboot,springcloud,spring cloud data fl ...

  3. rest-framework之权限组件

    权限 权限 作用 : 校验用户是否有权限访问 检测权限肯定是在用户认证通过之后,所有可以直接在request中取出用户做判断 先定义一个类,继承 BasePermission. from rest_f ...

  4. App 性能相关

    51Testing系列丛书:性能测试学习笔记之 LoadRunner实战 http://www.51testing.com/html/38/n-3723938.html

  5. Java工程师修炼之路(从小白到BAT的两年学习历程)

    ​ 作者:陆小凤 文章首发于:微信公众号[程序员江湖] 前言 在下本是跨专业渣考研的985渣硕一枚,经历研究生两年的学习积累,有幸于2019秋季招聘中拿到几个公司的研发岗offer,包括百度,阿里,腾 ...

  6. MySQL高可用新玩法之MGR+Consul

    前面的文章有提到过利用consul+mha实现mysql的高可用,以及利用consul+sentinel实现redis的高可用,具体的请查看:http://www.cnblogs.com/gomysq ...

  7. leetcode — maximum-subarray

    /** * * Source : https://oj.leetcode.com/problems/maximum-subarray/ * * Created by lverpeng on 2017/ ...

  8. MODIS数据的下载(新地址)

    Modis数据下载方法 1.1打开网址 浏览器输入地址:https://ladsweb.nascom.nasa.gov/search 注:需要一定的等待时间,如果一直打不开,就需要FQ.(网址加载了g ...

  9. 【原创】驱动卸载之ControlService函数

    BOOL WINAPI ControlService( _In_ SC_HANDLE hService, _In_ DWORD dwControl, _Out_ LPSERVICE_STATUS lp ...

  10. [转]rancher 初步

    本文转自:https://blog.csdn.net/weixin_41709748/article/details/81515780 什么是 rancher Rancher是一个开源的企业级全栈化容 ...