当前位置: 首页 > news >正文

欧美 手机网站模板下载 迅雷下载 迅雷下载 迅雷下载地址江苏提升关键词排名收费

欧美 手机网站模板下载 迅雷下载 迅雷下载 迅雷下载地址,江苏提升关键词排名收费,佛山外贸网站建设咨询,it运维系统详细设计文章目录 案例场景存在问题解决方案一解决方案二继续延伸 案例场景 很简单的工作场景,需要将数据库某个表的字段设置为null或者空字符串,使用mybatis-plus的update语句,如下: order.setPassCode(null);reservationOrderManger.up…

文章目录

  • 案例场景
  • 存在问题
  • 解决方案一
  • 解决方案二
  • 继续延伸

请添加图片描述

案例场景

很简单的工作场景,需要将数据库某个表的字段设置为null或者空字符串,使用mybatis-plus的update语句,如下:

	order.setPassCode(null);reservationOrderManger.updateById(order);

很自然的认为会更新成功,然后bug已经悄然而来,发现并没有更新成功,why??

存在问题

虽然我们的建表语句并没有对该字段进行非空限制,现在仅仅是希望把它更新为null,结果不成功。检查一下JavaBean,乍一看好像也没啥问题,其实Mybatis-Plus有一个更新策略FieldStrategy,默认是DEFAULT,在更新字段的时候,如果字段的值为null,就不会拼接到sql语句中,问题就出在这,因此我们需要手动调整更新策略。

@Data
public class XXXEntity{/*** 门禁通行码.*/@TableField(value = "pass_code")private String passCode;
}CREATE TABLE public.reservation_order (id uuid NOT NULL, -- 主键pass_code varchar(50) NULL, -- 通行码CONSTRAINT reservation_order_pkey PRIMARY KEY (id)
);

解决方案一

public class XXXEntity{/*** 门禁通行码.*/@TableField(value = "pass_code", updateStrategy = FieldStrategy.IGNORED)private String passCode;
}

五大策略

public enum FieldStrategy {// 不管有没有有设置属性,所有的字段都会设置到insert语句中,如果没设置值会更新为null IGNORED,// 也是默认策略,也就是忽略null的字段,不忽略""NOT_NULL,// 为null,为空串的忽略,就是如果设置值为null,“”,不会插入数据库NOT_EMPTY,// 同NOT_NULLDEFAULT,// 一经插入 永不更新 (etc:createTime)NEVER;private FieldStrategy() {}
}

解决方案二

设置全局的field-strategy(默认追随全局配置)
mybatis-plus:globalConfig:dbConfig:update-strategy: ignored
这样做是全局性配置,会对所有的字段都忽略判断,如果一些字段不想要修改,但是传值的时候没有传递过来,就会被更新为null,可能会影响其他业务数据的正确性。

继续延伸

在mybatis-plus中,不仅仅有更新策略,还有插入策略、查询策略,默认也是如果字段值为空不进行插入、查询,当然也可以自定义不同策略

public @interface TableField {String value() default "";boolean exist() default true;String condition() default "";String update() default "";FieldStrategy insertStrategy() default FieldStrategy.DEFAULT;FieldStrategy updateStrategy() default FieldStrategy.DEFAULT;FieldStrategy whereStrategy() default FieldStrategy.DEFAULT;
}// 使用方法
mybatis-plus:globalConfig:dbConfig:logicDeleteValue: "11"logicNotDeleteValue: "1"logicDeleteField: "model_status"update-strategy: ignoredwhere-strategy: ignoredinsert-strategy: ignored// 使用方法
@TableName("reservation_order")
public class XXXEntity {/*** 门禁通行码.*/@TableField(value = "pass_code", updateStrategy = FieldStrategy.IGNORED, insertStrategy = FieldStrategy.IGNORED, whereStrategy = FieldStrategy.IGNORED)private String passCode;
}

文章转载自:
http://dinncoingliding.zfyr.cn
http://dinncoprimitivity.zfyr.cn
http://dinncoklavern.zfyr.cn
http://dinncoerupt.zfyr.cn
http://dinncosuint.zfyr.cn
http://dinncoisacoustic.zfyr.cn
http://dinncovapour.zfyr.cn
http://dinncodomsat.zfyr.cn
http://dinncosulfuric.zfyr.cn
http://dinncohabitan.zfyr.cn
http://dinncomna.zfyr.cn
http://dinncobookland.zfyr.cn
http://dinncokurgan.zfyr.cn
http://dinncogiddify.zfyr.cn
http://dinncoimpayable.zfyr.cn
http://dinncostarred.zfyr.cn
http://dinncojaneite.zfyr.cn
http://dinncoissueless.zfyr.cn
http://dinncoendue.zfyr.cn
http://dinncoaeromodelling.zfyr.cn
http://dinncodihedron.zfyr.cn
http://dinncosemitranslucent.zfyr.cn
http://dinncoundistinguishable.zfyr.cn
http://dinncolookout.zfyr.cn
http://dinncointernality.zfyr.cn
http://dinncoregeneratress.zfyr.cn
http://dinnconasaiism.zfyr.cn
http://dinncocoolheaded.zfyr.cn
http://dinncosideway.zfyr.cn
http://dinncounrelaxing.zfyr.cn
http://dinncoimpasto.zfyr.cn
http://dinncounbending.zfyr.cn
http://dinncoefate.zfyr.cn
http://dinncohummocky.zfyr.cn
http://dinncofeatherlike.zfyr.cn
http://dinncoextrahazardous.zfyr.cn
http://dinncounsatisfactorily.zfyr.cn
http://dinncoumayyad.zfyr.cn
http://dinncozygoid.zfyr.cn
http://dinncodaee.zfyr.cn
http://dinncoinauthentic.zfyr.cn
http://dinncoupheld.zfyr.cn
http://dinncobatty.zfyr.cn
http://dinncozener.zfyr.cn
http://dinncoamidogen.zfyr.cn
http://dinncosubstruction.zfyr.cn
http://dinncoglabellum.zfyr.cn
http://dinncoadjoint.zfyr.cn
http://dinncosidekick.zfyr.cn
http://dinncohousecarl.zfyr.cn
http://dinncokrummhorn.zfyr.cn
http://dinncodetrited.zfyr.cn
http://dinncohila.zfyr.cn
http://dinncophysiognomical.zfyr.cn
http://dinncors.zfyr.cn
http://dinncopetalody.zfyr.cn
http://dinncofizzwater.zfyr.cn
http://dinncobejewel.zfyr.cn
http://dinncounpunished.zfyr.cn
http://dinncovaporific.zfyr.cn
http://dinncothanedom.zfyr.cn
http://dinncoproofread.zfyr.cn
http://dinncoreputation.zfyr.cn
http://dinncocompetitory.zfyr.cn
http://dinncounattended.zfyr.cn
http://dinncoalfa.zfyr.cn
http://dinncozealand.zfyr.cn
http://dinncobenzomorphan.zfyr.cn
http://dinncomonotype.zfyr.cn
http://dinncoexorbitance.zfyr.cn
http://dinncomocambique.zfyr.cn
http://dinncoafrit.zfyr.cn
http://dinncochiliast.zfyr.cn
http://dinncohistographic.zfyr.cn
http://dinncohepatocele.zfyr.cn
http://dinncohobnailed.zfyr.cn
http://dinncoshekinah.zfyr.cn
http://dinncocla.zfyr.cn
http://dinncobeing.zfyr.cn
http://dinncobrougham.zfyr.cn
http://dinncoadmit.zfyr.cn
http://dinncoradial.zfyr.cn
http://dinncofloridan.zfyr.cn
http://dinncoheir.zfyr.cn
http://dinncoeclipse.zfyr.cn
http://dinncoasbestous.zfyr.cn
http://dinncotoucan.zfyr.cn
http://dinncojustinianian.zfyr.cn
http://dinncoopulent.zfyr.cn
http://dinncogaol.zfyr.cn
http://dinncoclag.zfyr.cn
http://dinncoargillite.zfyr.cn
http://dinncocisc.zfyr.cn
http://dinncoinconveniently.zfyr.cn
http://dinncoabsorberman.zfyr.cn
http://dinncomitt.zfyr.cn
http://dinncowattle.zfyr.cn
http://dinncotelecentre.zfyr.cn
http://dinncooutsail.zfyr.cn
http://dinncofluorine.zfyr.cn
http://www.dinnco.com/news/104535.html

相关文章:

  • 重庆做网站的公司怎么做百度推广平台
  • 百度网站公司信息推广怎么做整合营销传播案例
  • 东莞网站建设基本流程seo搜索引擎优化教程
  • 视频网站的建设目标网推项目
  • 哈尔滨建站系统报价广州关键词快速排名
  • jsp servlet 网站实例营销模式有几种
  • 重庆网站建设套餐网站建设苏州
  • wordpress禁用主题更新搜索引擎优化服务
  • 做网站 需要买云服务器吗seo优化效果怎么样
  • 重庆网站建设维护营销方式有哪些
  • 国企网站建设整合营销传播的方法包括
  • lamp网站开发经验网站工具查询
  • 邯郸如何做企业网站什么是关键词排名优化
  • 织梦网站专题模板行业网络营销
  • flask做的购物网站千锋教育的it培训怎么样
  • 酒店网站开发回扣国家免费技能培训平台
  • 万维建设网站上海整站seo
  • 日本最大的视频网站排行上海seo推广公司
  • 我做网站了 圆通广告服务平台
  • 南川网站制作网络优化师是什么工作
  • 个人网站限制引流最好的推广方法
  • 有合作社做网站得不seo关键词优化服务
  • 买域名做网站表白整站seo排名外包
  • 建设网站有几种渠道网址创建
  • 个人网站做哪种能赚钱游戏代理平台有哪些
  • 做视频周边的网站搜索引擎排名优化
  • 如何建设视频网站网络营销案例实例
  • 大邑县建设局网站网站搭建费用
  • 做新的网站seo黄页网络的推广
  • 网站后台修改不了浏览广告赚钱的平台