mybatis之CRUD中的方法

一. updateByExampleSelective(record,example)

  1.第一个参数record,是一个new的实体类,是与数据库表对应的实体类,该实体类中要修改的字段给我们想给的值

        不变的字段默认为null.就是实体类中有值的字段去数据库中修改,为null的字段则保持原来的值.

 2.第二个参数,是我们给的条件,或者是前端传过来的条件,将数据库中符合该条件的数据进行修改

    3.下面给出一个例子

  

   
public void deleteEbizChannel(List<Integer> list) {
   //创建条件
EbizChannelExample ebizChannelExample = new EbizChannelExample();
EbizChannelExample.Criteria criteria = ebizChannelExample.createCriteria();
  //数据库中id字段在传过来的集合中的
criteria.andIdIn(list);
  //创建实体类,并给我们想对数据库进行修改的字段赋值,这里是isDelete字段
EbizChannel ebizChannel = new EbizChannel();
ebizChannel.setIsDelete(1);
  //执行操作
ebizChannelDao.updateByExampleSelective(ebizChannel,ebizChannelExample);
}

待续.....

原文地址:https://www.cnblogs.com/jiushixihuandaqingtian/p/11213010.html