Tencent / APIJSON

🏆 实时 零代码、全功能、强安全 ORM 库 🚀 后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构 🏆 Real-Time coding-free, powerful and secure ORM 🚀 providing APIs and Docs without coding by Backend, and the returned JSON of API can be customized by Frontend(Client) users
http://apijson.cn
Other
17.14k stars 2.15k forks source link

希望对apijson事务有一个系统的介绍 #674

Open hongxiao2016 opened 8 months ago

hongxiao2016 commented 8 months ago

Description

对于6.3.0版本的使用,我是一个新手,在学习了解apijson的时候,尤其是事务这一块,比较晕,看了很多文档还是晕,感觉比较散,看到了很多说明,比如说Function实现事务,重写begin、commit、rollback等自己手动统一进行事务控制,还有判断是否为最后一条sql等等,也在网上看到某个“火车票”相关的系统,但是由于版本的问题,很多东西变了,但是最终还是没有解决问题。

猜想:

  1. 前段处理: 发送请求的时候就指定这个是“事务”
  2. 后端处理:开始执行sql前、执行发生异常时、没有异常顺利执行完 是否会有切面让用户控制事务。

有相关的事务demo吗?求求大佬了,这个项目真的是极好的,谢谢大佬。

TommyLemon commented 8 months ago

GET, HEAD 这两个查询方法默认不开事务,其它默认开启。 事务是在后端控制,保证安全和避免脏数据,可以重写 setAutoCommit, onCommit, onRollback 等方法自定义

https://github.com/Tencent/APIJSON/issues/531 https://github.com/Tencent/APIJSON/issues/572 https://github.com/Tencent/APIJSON/issues/270#issuecomment-972578669 https://github.com/Tencent/APIJSON/issues/468

TommyLemon commented 8 months ago

所有 Demo 中的所有通用 增/删/改 接口全都是自动处理事务,没有特殊需求的不需要额外处理,如果执行了远程函数,只要抛异常即可自动触发 roll back 事务回滚 https://github.com/APIJSON/APIJSON-Demo/tree/master/APIJSON-Java-Server