updateByExampleSelective 参数理解

DiReceiveMsg receiveMsg = new DiReceiveMsg();
            receiveMsg.setUpdateTime(DateUtils.formatDate("2019-10-10 10:10:10",DiConstants.DATEFORMAT_YYYY_MM_DD_HH_mm_ss));
            receiveMsg.setCreateTime(DateUtils.formatDate("2019-10-10 10:10:10",DiConstants.DATEFORMAT_YYYY_MM_DD_HH_mm_ss));
            date = DateUtils.addSeconds(date,1);
            DiReceiveMsgExample receiveMsgExample = new DiReceiveMsgExample();
            receiveMsgExample.createCriteria().andUpdateTimeEqualTo(date);
            diReceiveMsgMapper.updateByExampleSelective(receiveMsg,receiveMsgExample);
            System.out.println(">>>>>>>>>>更新update_time时间"+DateUtils.formatDate(date,DiConstants.DATEFORMAT_YYYY_MM_DD_HH_mm_ss)+">>>>>>>>>>>>>>");

updateByExampleSelective有两个参数 

参数1:receiveMsg 这个对象是真正修改的参数:

参数2:  receiveMsgExample 这个条件是sql   where后的查询条件;

以下是执行后的sql,代码中的需求是我把所有的创建时间和修改时间改成   "2019-10-10 10:10:10" 。

JDBC Connection [org.postgresql.jdbc.PgConnection@42107318] will not be managed by Spring
==>  Preparing: update di_receive_msg SET create_time = ?, update_time = ? WHERE ( update_time = ? ) 
==> Parameters: 2019-10-10 10:10:10.0(Timestamp), 2019-10-10 10:10:10.0(Timestamp), 2019-12-30 11:23:25.0(Timestamp)
<==    Updates: 330
 

你可能感兴趣的:(java)