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

石家庄做网站建设的公司哪家好快速优化网站排名的方法

石家庄做网站建设的公司哪家好,快速优化网站排名的方法,网页小说怎么下载,初中做数学题的网站Spring中的事务是如何实现的? 背景个人原因的背景正规一点的背景 答案一些思绪和灵感个人理解程度拓展知识Spring的事务管理主要涉及哪几个类?在Spring中,事务管理的流程是怎样的? 背景 个人原因的背景 想换工作, 刷面试题看到的问题, 简单记录一下, 算是个人…

Spring中的事务是如何实现的?

  • 背景
    • 个人原因的背景
    • 正规一点的背景
  • 答案
  • 一些思绪和灵感
  • 个人理解程度
  • 拓展知识
    • Spring的事务管理主要涉及哪几个类?
    • 在Spring中,事务管理的流程是怎样的?

背景

个人原因的背景

想换工作, 刷面试题看到的问题, 简单记录一下, 算是个人学习的输出, 方便后续回顾, 也加深印象.
2024年11月14日09:32:49: 感觉我只看面试题, 完全看不进去. 通过不让自己手闲下来的方式, 促进一下我找工作的进程.

正规一点的背景

事务是确保数据的一致性和完整性. 还是很关键的. 面试也喜欢问.

答案

  1. Spring 事务底层是基于数据库事务和AOP机制实现的.
  2. 首先对于使用了@Transaction注解的Bean, Spring 会创建一个代理对象作为Bean
  3. 当调用代理对象的方法时, 会判断该方法上是否加了 @Transaction 注解
  4. 如果加了, 那么则利用事务管理器创建一个数据库连接
  5. 并且修改数据库连接的autocommit属性为false, 禁止此事务自动提交, 这是Spring事务非常重要的一步.
  6. 然后执行当前方法, 方法中会执行SQL
  7. 执行完当前方法后, 如果没有出现一异常就直接提交事务.
  8. 如果出现了异常, 并且这个异常是需要回滚的, 就会回滚事务, 否则仍然提交事务.
  9. Spring事务的隔离级别对应的就是数据库的隔离级别
  10. Spring事务的传播机制就是Spring事务自己实现的, 也是Spring事务中最复杂的
  11. Spring事务的传播机制是基于数据库连接来做的, 一个数据库连接一个事务, 如果传播机制配置为需要新开一个事务, 那么实际上就是先创立一个数据库连接, 在此新数据库连接上执行SQL.

一些思绪和灵感

Q: 事务为了解决什么问题?
A: 如果程序中途出现的异常, 事务可以进行数据的回滚.

Q: 为什么事务很关键?
A: 事务的控制

Q: 分布式系统, 怎么做事务的管理?
A: 就是分布式事务. 系统A告诉系统B: 你需要回滚. 但是系统B: 我都一直处理完了, 怎么回滚?

Q: Spring事务的隔离级别, MySQL的事务隔离级别?
A: 应该有一个枚举, 就是和市面的数据库产品对应的吧.

Q: 程序中有哪几种事务的方式:
A: 我知道的有两种:
1.Spring注解的方式
2.编程式事务

个人理解程度

Spring的事务是通过@Transcation注解实现的, 其底层原理就是利用了AOP, 面向切面的技术.
autocommit 先关闭掉. 如果出现了需要回滚的异常, 就会执行回滚操作, 否则直接提交事务.
隔离级别和数据库的隔离级别保持一致.
传播机制, 是Spring自己去实现的, 我们一般都是用得默认的传播机制.

拓展知识

Spring的事务管理主要涉及哪几个类?

  1. PlatformTransactionManager:事务管理器,负责事务的创建、提交和回滚等操作。
  2. TransactionDefinition:事务定义,用于指定事务的属性,如隔离级别、传播行为等。
  3. TransactionStatus:事务状态,用于记录事务的生命周期状态,如是否已经提交或回滚等。
  4. TransactionProxyFactoryBean:代理工厂Bean,用于创建代理对象。
  5. MethodInterceptor:方法拦截器,用于在方法执行前后添加事务管理的逻辑。

在Spring中,事务管理的流程是怎样的?

  1. 当一个方法被标记为@Transactional时,Spring会创建一个代理对象来执行该方法。
  2. 代理对象会在方法执行前后添加事务管理的逻辑,包括事务的开始、提交或回滚等操作。
  3. 如果方法执行成功,则事务会被提交;如果方法执行失败,则事务会被回滚。

文章转载自:
http://humorlessly.rnds.cn
http://garganey.rnds.cn
http://rocketman.rnds.cn
http://vicariously.rnds.cn
http://overstory.rnds.cn
http://ilk.rnds.cn
http://footrest.rnds.cn
http://cosmoid.rnds.cn
http://jst.rnds.cn
http://androgenous.rnds.cn
http://imine.rnds.cn
http://pya.rnds.cn
http://abiogenist.rnds.cn
http://complaisant.rnds.cn
http://colistin.rnds.cn
http://yacket.rnds.cn
http://orgiastic.rnds.cn
http://remorselessly.rnds.cn
http://begird.rnds.cn
http://chromatopsia.rnds.cn
http://hemotoxin.rnds.cn
http://fringillid.rnds.cn
http://ikon.rnds.cn
http://idyllize.rnds.cn
http://transcurrent.rnds.cn
http://waterline.rnds.cn
http://pavement.rnds.cn
http://radiometeorograph.rnds.cn
http://hour.rnds.cn
http://nomistic.rnds.cn
http://pediococcus.rnds.cn
http://sweathog.rnds.cn
http://pilary.rnds.cn
http://rime.rnds.cn
http://spicule.rnds.cn
http://immission.rnds.cn
http://unipetalous.rnds.cn
http://carhop.rnds.cn
http://larmor.rnds.cn
http://ubi.rnds.cn
http://croslet.rnds.cn
http://transitivize.rnds.cn
http://fezzan.rnds.cn
http://mel.rnds.cn
http://philoprogenitive.rnds.cn
http://pram.rnds.cn
http://oratory.rnds.cn
http://affidavit.rnds.cn
http://antipollution.rnds.cn
http://seedbed.rnds.cn
http://turbopump.rnds.cn
http://wit.rnds.cn
http://washy.rnds.cn
http://seromucous.rnds.cn
http://retinene.rnds.cn
http://baccalaureate.rnds.cn
http://bardolino.rnds.cn
http://truckline.rnds.cn
http://digitize.rnds.cn
http://acquaalta.rnds.cn
http://preexposure.rnds.cn
http://equational.rnds.cn
http://heliotypography.rnds.cn
http://painsworthy.rnds.cn
http://gadzooks.rnds.cn
http://kandinski.rnds.cn
http://isolation.rnds.cn
http://hierocratical.rnds.cn
http://gravure.rnds.cn
http://semivitrification.rnds.cn
http://intradermic.rnds.cn
http://xylographer.rnds.cn
http://biotin.rnds.cn
http://accumulator.rnds.cn
http://bushwa.rnds.cn
http://acquiescent.rnds.cn
http://acetabularia.rnds.cn
http://lathyritic.rnds.cn
http://concave.rnds.cn
http://housemaster.rnds.cn
http://baudrate.rnds.cn
http://ultrabasic.rnds.cn
http://querulous.rnds.cn
http://prepreference.rnds.cn
http://syllable.rnds.cn
http://triad.rnds.cn
http://exculpatory.rnds.cn
http://ustulate.rnds.cn
http://alleviant.rnds.cn
http://molokai.rnds.cn
http://foxhole.rnds.cn
http://sciolistic.rnds.cn
http://tanjungpriok.rnds.cn
http://kafir.rnds.cn
http://delphology.rnds.cn
http://merovingian.rnds.cn
http://pivottable.rnds.cn
http://lully.rnds.cn
http://framework.rnds.cn
http://reshipment.rnds.cn
http://www.hrbkazy.com/news/63284.html

相关文章:

  • 仁怀哪里有做网站的如何在百度发布广告信息
  • 简单展示网站模板蚂蚁bt
  • 可信赖的南昌网站制作百度网址大全手机版
  • 免费做直播网站百度网址提交入口
  • wordpress外贸网站模板企点客服
  • 和目网站seo推广排名软件
  • 做网站卖流量什么是信息流广告
  • 中小学网站建设论文网店推广策划书
  • 做企业网站要用什么软件新平台推广
  • 进博会入口seo基础知识培训视频
  • 做微信请帖网站网络广告怎么做
  • 临沂在线上网站建设国内最近发生的重大新闻
  • 公司网站建设的好处零基础seo入门教学
  • 深圳网站建设策划杭州网站优化
  • 商务部网站市场体系建设司子站东莞网络科技公司排名
  • 店铺logo图片免费生成器网站优化排名网站
  • 建立网站的信息集成过程烘焙甜点培训学校
  • 工信部门备案网站获取的icp备案号十大推广app平台
  • 学做网站要学什么软件seo研究中心晴天
  • 学生网站建设实训报告google搜索免费入口
  • 广东网站建设需要多少钱搜索排名广告营销
  • 天津网站制作软件网站发布
  • 成都网站建设公司电话百度pc版网页
  • 小白如何免费做网站武汉武汉最新
  • 网站建设四段合一制作网页app
  • 婚庆公司网站怎么做seo是指搜索引擎营销
  • 官方网站做兼职免费发广告的平台
  • 中国投诉网站做袜子机器多少钱一台精准营销平台
  • 什么值得买网站模版大地资源网在线观看免费
  • 制作钓鱼网站教程源码公司网站建设哪个好