IGNORED:0 忽略NOT_NULL:1 非 NULL,默认策略NOT_EMPTY:2 非空 而默认更新策略是NOT_NULL:非 NULL;即通过接口更新数据时数据为NULL值时将不更新进数据库。三、解决方案 1. 设置全局的field-strategy properties文件格式:mybatis-plus.global-config.db-config.field-strategy=ignored yml文件格式:mybatis-...
mpg.setCfg(cfg);//自定义模板配置,可以 copy 源码 mybatis-plus/src/main/resources/templates 下面内容修改,//放置自己项目的 src/main/resources/templates 目录下, 默认名称一下可以不配置,也可以自定义模板名称//TemplateConfig tc = new TemplateConfig();//tc.setController("...");//tc.setEntity("....
db-config:#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";id-type: UUID#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"field-strategy: NOT_EMPTY#驼峰下划线转换table-underline:true#mp2.3+ 全局表前缀 mp_#table-prefix: mp_...
COLUMN_MAP) Map<String, Object> columnMap); /** * 根据 entity 条件,删除记录 * * @param wrapper 实体对象封装操作类(可以为 null) */ int delete(@Param(Constants.WRAPPER) Wrapper<T> wrapper); /** * 删除(根据ID 批量删除) * * @param idList 主键ID列表(不能为 null 以及 empty) */ ...
NOT_NULL not_empty (为"")也是忽略 ignored 就空的也插入 但是有风险 在更新时候 但是在实体类中, 个别的,可以在字段上配置TableField(stragegyFieldStrategy.NOT_EMPTY),就是字段为""的时候也忽略 同样的就近原则 tablePrefix 表名前缀 全局 mybatis-.global-config.db-config.tableprefix=通用...
isEmpty(email), "email", email); List<User> users = userMapper.selectList(queryWrapper); users.forEach(System.out::println); } 5.传入实体参数 // 设置name前后模糊 @TableField(condition = SqlCondition.LIKE) private String name; /** * 传入实体对象 */ @Test public void selectWrapper12()...
Assert.notEmpty(keyProperty, "error: can not execute. because can not find column for id from entity!", new Object[0]); Object idVal = ReflectionKit.getFieldValue(entity, tableInfo.getKeyProperty()); return !StringUtils.checkValNull(idVal) && !Objects.isNull(this.getById((Serializable)idVal...
NOT_NULL:非NULL校验。只会将非NULL的字段组装到 SQL 语句中 NOT_EMPTY:非空校验。当有字段是字符串类型时,只组装非空字符串;对其他类型的字段,等同于NOT_NULL NEVER:不加入 SQL。所有字段不加入到 SQL 语句 tablePrefix:添加表名前缀 比如 mybatis-plus: global-config: db-config: table-prefix: xx_ ...
= null 这样的参数,意思就是当条件成立时才会添加这个查询条件,类似Mybatis的mapper.xml文件中的<if>标签。这样就实现了动态查询条件效果了。 不过,上述条件构建的代码太麻烦了。 因此Service中对LambdaQueryWrapper和LambdaUpdateWrapper的用法进一步做了简化。我们无需自己通过new的方式来创建Wrapper,而是直接调用lambda...
几乎所有的条件构造函数,都提供了condition参数实现动态SQL。也就是参数判断是否返回true,如果返回false,该条件不成立。如email=“”,所以.like(StringUtils.isNotEmpty(email), "email", email);的条件不成立。 所以最终的执行SQL,如下(只有name LIKE条件,没有email LIKE 条件): SELECT id,name,age,email,create...