Comments (11)
多谢反馈,我们会尽快调整!
from mybatis-plus.
这个问题在git.oschina上dev分支已修复,将在下个版本解决
from mybatis-plus.
2.0.6-jdk8 里面,在同一个会话里,多次调用同一个语句,还是会异常。
比如原始语句是 update xx set version = ? and xx = ? where id = ?
处理后的语句是 update xx set version = ? and xx = ? where version = ? and id = ?
第一次调用时,前面的version的值会+1,后面的version会添加一个参数;
第二次调用时,不会处理(因为prepare在同一个会话里根据sql有缓存,第二次调用直接取缓存,不会调用插件再处理)
应该还是需要在executor的地方拦截,prepare不行。
from mybatis-plus.
非常感谢,已经着手查看该问题了
from mybatis-plus.
提个思路吧,还是拦截StatementHandler,但是换成拦截getBoundSql这个方法,
处理sql的时候,不能添加额外的参数,版本号的值需要直接设置到sql语句里面去。
比如原来有 set version = ? 就改成 set version = ? + 1,没有,就改成 set version = version + 1
条件里如果原来有 version = ? 就不处理,没有就处理成 version = 具体的值(具体的根据version的类型在versionHandler里处理)
getBoundSql会在prepare之前处理,应该可以这样处理。
from mybatis-plus.
顺便提一句,如果@Version注解是在父类上,最新版本还是不管用的
from mybatis-plus.
@kevin82008 抱歉! 请等一等我们的正式版 2.0.6
from mybatis-plus.
@kevin82008 Mybatis的plugin仅支持:
MyBatis allows you to intercept calls to at certain points within the execution of a mapped statement. By default, MyBatis allows plug-ins to intercept method calls of:
Executor (update, query, flushStatements, commit, rollback, getTransaction, close, isClosed)
ParameterHandler (getParameterObject, setParameters)
ResultSetHandler (handleResultSets, handleOutputParameters)
StatementHandler (prepare, parameterize, batch, update, query)
http://www.mybatis.org/mybatis-3/configuration.html#plugins
from mybatis-plus.
我试过,可以拦截getBoundSql方法,不过官方声明上确实没有
from mybatis-plus.
@kevin82008 这么神奇,不过不是很推荐,万一官方版本升级了,去掉了这个,那不就GG了
from mybatis-plus.
@kevin82008 我试过拦截getBoundSql,确实可以. 但是普通模式就不能用了.
这个插件主要是我在负责,确实没什么好的思路了. 在Executor上拦截有很多问题的.
如果你要用重用模式不然手动复制一下自己拦截getBoundSql.
from mybatis-plus.
Related Issues (20)
- 在继承ServiceImpl的实现类中自动注入失效 HOT 4
- An error occurred while adding a service to the nacos registry using dubbo3 HOT 1
- 翻页插件问题 HOT 1
- An error occurred while adding a service to the nacos registry using dubbo3 HOT 1
- 对 #5745 的优化导致分页查询中如包含distinct跟orderby会导致sqlserver语法错误 HOT 3
- count错误 HOT 3
- AESEncryptHandler继承BaseTypeHandler实现部分字段加密解密,单条数据查询时不会进入AESEncryptHandler HOT 10
- mybatis plus generator 禁止生成serviceImpl、mapper、xml、controller失效 HOT 1
- 达梦数据库无法匹配到owner=‘%s’ 问题 HOT 4
- oracle updateBatchById ORA-01461 HOT 1
- oracle updateBatchById ORA-01461
- 在win11+jdk21环境下,自动生成代码只会输出表名,一直卡住,不知道为什么 HOT 4
- ISSUES反馈注意事项
- 有点没理解 TableField fill属性的设计** HOT 6
- 今天使用 parent 和 moduleName,结果 VelocityTemplateEngine模板的package.Parent是parent.moduleName HOT 3
- TableInfo懒加载 HOT 1
- json相关函数会有错误 HOT 1
- 使用DataPermissionInterceptor插件时,BaseMapper自带的CRUD报错,如selectById等会报:未找到对应的mapper方法 HOT 1
- 如何获取QueryWrapper中的参数名称 HOT 3
- Generator生成对象时,如何指定对象属性类型为枚举类型?
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 mybatis-plus.