Comments (9)
我觉得没必要吧,只要没有出现异常,肯定是成功的,你怎么看?
from spring-boot-api-project-seed.
public void save(T model) {
mapper.insertSelective(model);
}
public void save(List<T> models) {
mapper.insertList(models);
}
public void deleteById(Integer id) {
mapper.deleteByPrimaryKey(id);
}
public void deleteByIds(String ids) {
mapper.deleteByIds(ids);
}
public void update(T model) {
mapper.updateByPrimaryKeySelective(model);
}
你说的是这些吧?Mapper确实是会返回影响的行数,我把它省略了,因为在使用中从来没用到过。
from spring-boot-api-project-seed.
你这么说好像也有点道理,这就意味着。如果影响的行数为0,那么必定会抛异常?
from spring-boot-api-project-seed.
from spring-boot-api-project-seed.
是的,那这个影响行数对调用者来说就有意义了。
调用者可以知道按照某个条件是否 执行成功了。
from spring-boot-api-project-seed.
加上是很容易的,关键在于有多少人会去处理这个返回值?每次调用 Service
的CRUD方法都会去判断一下影响的记录数?
from spring-boot-api-project-seed.
这个在实际业务中,场景确实有的
from spring-boot-api-project-seed.
返回影响行数还是很有必要的,可以避免代码中锁的使用,如更新订单状态(update ... set status = 'success' where status = 'wait_paying'),更新成功(影响行数=1)执行后续的操作,否则表示订单已经被更新过,直接return
from spring-boot-api-project-seed.
更新一个条件不存在的时候就是0吧,感觉是需要拿返回值来作为下一步业务处理的依据
from spring-boot-api-project-seed.
Related Issues (20)
- 建议视频放在B站 HOT 5
- {"code":500,"message":"接口 [/thetrainlist/list/] 内部错误,请联系管理员"} HOT 2
- 为啥我生成了3个文件夹,不是包呢。
- 请问有将springboot升级到2.X计划吗?有的话大概什么时候?
- 根据添加的依赖生成对应的application配置
- 建议把Controller、Service、DAO和和三方对接的模板都写一下
- 验签拦截器获取不到请求头中的数据
- "message": "接口 [/user/add] 内部错误,请联系管理员"
- "message": "接口 [/user/add] 内部错误,请联系管理员"bug已解决 HOT 2
- resource下面没有mapper文件 HOT 3
- 前后端分离项目,vue+boot,针对这个工程里面有需要改动的地方吗?
- 去掉fastjson的依赖吧 HOT 1
- 【招聘向】大厂机会,将这个项目应用到生产吧 HOT 1
- 大神对RESTful 有点误解吧 HOT 6
- 停更了? HOT 1
- 返回的对象是空,是什么原因 HOT 2
- 大佬加个相关项目链接呗 HOT 1
- 【项目自荐】: ❤️一个基于Springboot的个人博客 HOT 1
- 来个 springboot2.x最新版的吧?1.5有些老了?
- 建议
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot-api-project-seed.