boolean insert(T entity); //插入 boolean insertSelective(T entity); //选择性插入,null字段不插入 boolean insertBatch(List<T> entityList); //批量插入 delete相关 boolean deleteById(I id); //通过ID删除 boolean deleteByMap(Map<String, Object> columnMap); // 通过自定义MAP删除 boolean deleteSele...
/** * 版本号(用于乐观锁, 默认为 1) */ @Version @TableField(fill = FieldFill.INSERT) private Integer version; @Override public void insertFill(MetaObject metaObject) { this.strictInsertFill(metaObject, "version", Integer.class, 1); } Step4: 简单测试一下,可以看一下 控制台 打印的 sql 语...
insert相关 boolean insert(T entity); //插入 boolean insertSelective(T entity); //选择性插入,null字段不插入 boolean insertBatch(List entityList); //批量插入 delete相关 boolean deleteById(I id); //通过ID删除 boolean deleteByMap(Map columnMap); // 通过自定义MAP删除 boolean deleteSelective(T en...
int updateByPrimaryKeySelective(UserInfo record);} Service类调⽤userInfoDao的insert⽅法(此⽅法是来源于BaseMapper)。但是insert成功后没有返回主键userId。上⽹查了下,其他⼈都是这样设置,就会有主键返回。看到dao类⾥⾯⼀条注释,// int insert(UserInfo record); ,⼼⾥有个想法。这条注释...
(常用)方法:int updateByPrimaryKeySelective(T record); 说明:根据主键更新属性不为null的值 Delete(不常用,只进行伪删除) 方法:int delete(T record); 说明:根据实体属性作为条件进行删除,查询条件使用等号 方法:int deleteByPrimaryKey(Object key);
}@OverridepublicintupdateByExampleSelective(Student record, StudentExample example){return0; }@OverridepublicintupdateByExample(Student record, StudentExample example){return0; } } AI代码助手复制代码 SchoolController类,实现前端和后台的交互。自动注入学生业务实现类。
/** * 根据输入的学生信息进行条件检索 * 1. 当只输入用户名时, 使用用户名进行模糊检索; * 2. 当只输入邮箱时, 使用性别进行完全匹配 * 3. 当用户名和性别都存在时, 用这两个条件进行查询匹配的用 * @param student * @return */ List selectByStudentSelective(Student student); ...
insertSelective 和 updateByPrimaryKeySelective 中,是否判断字符串类型 !=”。 配置方式: notEmpty=true 更多配置:点击 @MapperScan 注解配置 你可以给带有 @Configuration 的类配置该注解,或者直接配置到 Spring Boot 的启动类上,如下: 代码语言:javascript
方法:int updateByExampleSelective(@Param("record") T record, @Param("example") Object example); 说明:根据Example条件更新实体record包含的不是null的属性值 方法:int deleteByExample(Object example); 说明:根据Example条件删除数据 测试: @RunWith(SpringRunner.class) ...
updateSelectiveById(T entity); //总是update非null非空白字符串字段 这样开发者可以自行调用要使用的update策略,比较灵活,也不必再配置updateStrategy。 insert方法同理。 重现步骤(如果有就写完整) 报错信息 无 👍1Saroth reacted with thumbs up emoji ...