如何更新我的电池: updateByPrimaryKeySelective (和updateByPrimaryKey ) )之间的差异
intupdatebyprimarykeyselective (tbitemrecord; intupdatebyprimarykey (tbitemrecord; 上面是逆转工程生成的Mapper接口
对应的xml为
更新id=' updatebyprimarykeyselective ' parameter type=' com.Taotao.POJO.TB item ' update TB _ itemsetiftest=' titl /if /set where id=#{id,JDBC type=bigint }/pdate--------------------。 jdbcType=VARCHAR},where id=#{id,JDBC type=bigint }/updateupdatebyprimarykeyselect
如果更新为空,则不保存空
updateByPrimaryKey更新您注入的所有字段,并将空字段在数据库中留空
@ overridepublicpagecommunitysearch (mapsearchmap )//通用映射器多条件搜索,标准表exampleexample=newexample ) community.class //指定查询的表tb_community //1。 初始化寻呼条件int pageNum=1; int pageSize=2; 搜索地图!=null (example.criteria criteria=example.create criteria ); //创建查询条件//时间区间if(stringutil.isnotempty () string (search map.get ) (starttime ) ) criteria.andgreaterthanorequque if(stringutil.isnotempty () string (search map.get ) (endtime ) ) Criteria.andlessthanorequalto ) (createtime ) ) 名称模糊搜索if(stringutil.isnotempty () string (search map.get ) (name ) ) ) Criteria.andlike (),(name ) ) ) % ) //分页符if((integer ) searchmap.get ) ' pagenum )!=null(pagenum=(integer ) searchmap.get ) ' pagenum ); (if ) (integer ) searchmap.get ) ' pagesize )!=null () pagesize=(integer ) searchmap.get('pagesize ); }pagehelper.startpage(pagenum,pageSize; 使用PageHelper插件完成分页pagecommunitycommunities=(page community ) community mapper.selectbyexample ) example; 返回通信; }