1.单个参数:mybatis不会特殊处理
#{参数名}:取出参数值
2.多个参数:mybatis会做特殊处理
多个参数会被封装成一个map,
key,param1...paramN,或者参数的索引也可以
#{ }就是从map中获取指定的key值
操作:
方法: public Employee getEmpByIdAndLastName(Integer id,String LastName);
取值:#{param1},#{param2}




3.命名参数:明确指定封装参数的map的key和@param("id")
多个参数会封装成一个map
key:使用@Param注解指定值
value:参数值
#{指定的key}取出对应的参数值


4.POJO:
如果多个参加正好是我们业务逻辑数据模型,我们就可以直接传入pojo
#{属性名}:取出传入的pojo的属性值
5.Map:
如果多个参数不是业务模型中的数据,但是经常要使用。


6.TO:
如果多个参数不是业务模型中的数据,但是经常要使用,推荐来编写一个TO(Transfer Object)数据传输对象
Page{
int index;
int size;
}
网友评论