Comments (6)
另外,填充逻辑似乎只支持一个类,如果有多种填充逻辑是需要自己在 一个类里进行区分实现吗?
from mybatis-plus.
ognl知道吧,ognl得到最终sql之后才会走填充,另外什么一个类八个类的,你要区分什么说清楚
from mybatis-plus.
ognl知道吧,ognl得到最终sql之后才会走填充,另外什么一个类八个类的,你要区分什么说清楚
要区分的类意思是:
例如针对实体A,我只要填充一个 updateUser 字段
针对实体B,我只要填充一个 updateTime 字段
只能在 handler的 updateFill(MetaObject obj)
里
if (obj.getOriginalObject() instance of A) {
setFieldValByName("updateUser", getUser(), metaObject);
} else if (obj.getOriginalObject() instance of A) {
setFieldValByName("updateTime", new Date(), metaObject);
}
用这样的写法,而不能在 @TableField 指定我应该使用哪个填充逻辑
from mybatis-plus.
就这样的啊,有什么问题?
from mybatis-plus.
就这样的啊,有什么问题?
就是想确认下有没有更优雅的方案而已。 那这第二个问题结了。
主要还是想确认下这个。
@TableField(fill=INSERT_UPDATE) 我只要在实体类的任意一个字段注解, 然后在handle里写字段注入逻辑就可以了。
所以感觉fill这个属性应该是注解到 Table层面, 而不是字段层面
from mybatis-plus.
ognl知道吧,ognl得到最终sql之后才会走填充,另外什么一个类八个类的,你要区分什么说清楚
要区分的类意思是:
例如针对实体A,我只要填充一个 updateUser 字段 针对实体B,我只要填充一个 updateTime 字段
只能在 handler的
updateFill(MetaObject obj)
里if (obj.getOriginalObject() instance of A) { setFieldValByName("updateUser", getUser(), metaObject); } else if (obj.getOriginalObject() instance of A) { setFieldValByName("updateTime", new Date(), metaObject); }if (obj.getOriginalObject() instance of A) { setFieldValByName(“updateUser”, getUser(), metaObject); } else if (obj.getOriginalObject() instance of A) { setFieldValByName(“updateTime”, new Date(), metaObject); }用这样的写法,而不能在 @TableField 指定我应该使用哪个填充逻辑
请问你的getUser()方法哪来的。。
from mybatis-plus.
Related Issues (20)
- 自定义类 实现 IDdl 接口,执行 SQL 某些关键词报错 HOT 2
- sqlArgsFill
- update(entity, updateWrapper),entity=null时MetaObjectHandler没触发,这个是基于什么考虑的 HOT 3
- 多数据源模式下切换数据源方言未正常切换导致分页报错 HOT 1
- 集成 PaginationInnerInterceptor后报错 HOT 2
- 多租户如何实现tenant_id in (1, 2) HOT 1
- 3.5.6xml中两行空行报错 HOT 1
- 代码生成器 HOT 1
- 因为MP加快了开发进度 导致我被裁员失去工作 MP 作者需要赔偿 HOT 70
- 分页插件返回IPage时包含请求参数的问题 HOT 3
- where()
- pgsql 主键id 使用uuid类型时 接口保存发生错误 HOT 5
- java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/extension/plugins/inner/InnerInterceptor HOT 2
- 在不设置FieldStrategy的情况下,批量更新怎么更新字段为null值
- 安全漏洞 HOT 2
- 生成了错误的(空)查询条件语句 HOT 2
- 救命,求修复SQL注入安全漏洞,更新一版3.5.7 HOT 22
- mybatis-plus-generator-3.5.6 oracle TIMESTAMP_WITH_TIMEZONE类型未维护
- ServuceImpl的saveOrUpdateBatch中校验是否需要更新是单条查询造成速度慢的优化 HOT 1
- mybatis-plus4 凉了吗~ HOT 3
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.