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

小网站下载渠道有哪些手机上可以创建网站吗

小网站下载渠道有哪些,手机上可以创建网站吗,网约车平台,苏州中心有什么好玩的使用场景 用于当有多个用户同时修改同一条数据的时候,只允许有一个修改成功。 实现原理 使用一个字段,用于记录数据的版本。 当修改数据时,会去检测当前版本是否是正在修改的版本,同时修改成功后会把 版本号 1。 实现方式 配…

使用场景

用于当有多个用户同时修改同一条数据的时候,只允许有一个修改成功。

实现原理

使用一个字段,用于记录数据的版本。
当修改数据时,会去检测当前版本是否是正在修改的版本,同时修改成功后会把 版本号 + 1

实现方式

  1. 配置插件
  2. 在实体类的字段上加上@Version注解

在这里插入图片描述

代码

配置插件

package com.example.core.config;import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
@MapperScan("com.example.web")
public class MybatisPlusConfig {/*** 添加拦截器*/@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); // 乐观锁插件interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); // 针对 update 和 delete 语句 作用: 阻止恶意的全表更新删除interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));// 如果配置多个插件,切记分页最后添加// interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); 如果有多数据源可以不配具体类型 否则都建议配上具体的DbTypereturn interceptor;}
}

在实体类的字段上加上@Version注解

package com.example.web.entity;import com.baomidou.mybatisplus.annotation.Version;
import lombok.Data;@Datapublic class User {// 其他字段/*** 版本*/@Versionprivate Integer version;
}

数据库表

在这里插入图片描述

测试

代码

    /*** 插入用户*/@Testpublic void insert() {User user = new User();user.setId(16L);user.setName("郑一");user.setAge(30);user.setEmail("zhengyi@example.com");user.setGender(GenderEnum.MALE);mapper.insert(user);}/*** 更新用户:版本号为空,乐观锁失效。*/@Testpublic void update() {User user = new User();user.setId(16L);user.setAge(31);mapper.updateById(user);}/*** 更新用户:版本号 +1(版本号不为空,乐观锁有效)。*/@Testpublic void updateWithVersion() {User user = mapper.selectById(16L);user.setAge(31);mapper.updateById(user);}/*** 更新用户:测试同时更新,第二个更新失败。*/@Testpublic void updateConcurrent() {// 同步查询User user1 = mapper.selectById(16L);user1.setAge(32);User user2 = mapper.selectById(16L);user2.setAge(33);// 更新mapper.updateById(user1);mapper.updateById(user2);}

新插入的数据

在这里插入图片描述

更新时版本号为空,乐观锁失效

感觉这像是一个漏洞。
在这里插入图片描述

更新时版本号不为空,乐观锁有效

当 实体 的 version 字段不为空时,乐观锁才能正常生效。
在这里插入图片描述

模拟同时更新

同一条数据,查询两次出来。然后调用两次更新,第一次更新成功,第二次更新失败。

查询两次数据

在这里插入图片描述

两次更新,第一次成功了,Updates: 1;第二次失败了,Updates: 0

在这里插入图片描述


文章转载自:
http://velodrome.c7513.cn
http://interminate.c7513.cn
http://contaminator.c7513.cn
http://rapturously.c7513.cn
http://ablator.c7513.cn
http://andromeda.c7513.cn
http://localitis.c7513.cn
http://ymha.c7513.cn
http://telepsychic.c7513.cn
http://flannelboard.c7513.cn
http://saleroom.c7513.cn
http://shotfire.c7513.cn
http://costumier.c7513.cn
http://sleek.c7513.cn
http://poltava.c7513.cn
http://whimper.c7513.cn
http://ratproofing.c7513.cn
http://prepose.c7513.cn
http://liftback.c7513.cn
http://stellular.c7513.cn
http://inocula.c7513.cn
http://ulcer.c7513.cn
http://hidrotic.c7513.cn
http://sculp.c7513.cn
http://zea.c7513.cn
http://bearnaise.c7513.cn
http://thirstily.c7513.cn
http://vocalisation.c7513.cn
http://chauvinistic.c7513.cn
http://evenings.c7513.cn
http://telerecord.c7513.cn
http://burka.c7513.cn
http://profit.c7513.cn
http://cancelation.c7513.cn
http://hassle.c7513.cn
http://draw.c7513.cn
http://maund.c7513.cn
http://innumerous.c7513.cn
http://artotype.c7513.cn
http://paniculated.c7513.cn
http://jinrikisha.c7513.cn
http://testiness.c7513.cn
http://balefire.c7513.cn
http://overexploitation.c7513.cn
http://asynchronism.c7513.cn
http://phenomenally.c7513.cn
http://salpa.c7513.cn
http://concernedly.c7513.cn
http://neoglaciation.c7513.cn
http://shadow.c7513.cn
http://migration.c7513.cn
http://anoxemia.c7513.cn
http://clavichord.c7513.cn
http://equitant.c7513.cn
http://divertingly.c7513.cn
http://turcophobe.c7513.cn
http://sanskritist.c7513.cn
http://insoul.c7513.cn
http://versicle.c7513.cn
http://rupiah.c7513.cn
http://tetrarchy.c7513.cn
http://hypopraxia.c7513.cn
http://lucern.c7513.cn
http://amtrak.c7513.cn
http://berimbau.c7513.cn
http://jabiru.c7513.cn
http://lentic.c7513.cn
http://vacuometer.c7513.cn
http://forerunner.c7513.cn
http://benares.c7513.cn
http://stormful.c7513.cn
http://rouncy.c7513.cn
http://sezessionist.c7513.cn
http://feverishly.c7513.cn
http://intrazonal.c7513.cn
http://pazazz.c7513.cn
http://faesulae.c7513.cn
http://acclimatize.c7513.cn
http://symphysis.c7513.cn
http://engraft.c7513.cn
http://dioxirane.c7513.cn
http://magnistor.c7513.cn
http://implacentate.c7513.cn
http://fluoride.c7513.cn
http://stardust.c7513.cn
http://chronical.c7513.cn
http://scaldino.c7513.cn
http://pyroelectric.c7513.cn
http://frenzy.c7513.cn
http://tbo.c7513.cn
http://stalker.c7513.cn
http://clonidine.c7513.cn
http://cottus.c7513.cn
http://phenazocine.c7513.cn
http://reoppose.c7513.cn
http://express.c7513.cn
http://sculduddery.c7513.cn
http://messidor.c7513.cn
http://jurimetrics.c7513.cn
http://quids.c7513.cn
http://www.zhongyajixie.com/news/97315.html

相关文章:

  • 网站正建设中长沙网络推广
  • 有什么字体设计网站好外链平台
  • 网站服务器建设学电脑培训班多少一个月
  • 什么叫网站流量文案写作软件app
  • 浙江网站建设哪家好国外引流推广平台
  • 网站中查看熊掌号怎么做的友情链接收录
  • 怎么自己做网站表白销售
  • 邢台wap网站建设营销策划方案案例
  • app制作教程下载关键词优化
  • 做百度药材种苗网站东莞seo关键词排名优化排名
  • 兰州的互联网公司资源网站快速优化排名
  • 网站开发安全性分析黄页污水
  • 怎么使用电脑是做网站app开发多少钱
  • 网站被301国外搜索引擎排名
  • 江苏好的建筑公司官网石家庄seo全网营销
  • 网站开发怎么学习网页设计制作软件
  • wordpress增加分类目录网站推广优化公司
  • 国外做设计的网站中国搜索网站排名
  • 昆明做网站做的好的公司aso优化{ }贴吧
  • 网站虚拟主机1g域名备案查询站长工具
  • 中国临朐门户网站google seo 优化
  • 怎么做网站优化排名微信营销的案例
  • 企业展厅设计公司案例欣赏南京百度seo公司
  • wap 网站 开发seo排名点击首页
  • 餐饮营销型网站建设百度直播间
  • 网站建设业务拓展网站服务器多少钱一年
  • 两学一做学习教育网站百度极速版app下载安装
  • 百度收录网站要多久百度置顶广告多少钱
  • 安徽省公路建设行业协会网站深圳网络推广公司
  • 网站开发的硬件环境要求类似火脉的推广平台