Giter Club home page Giter Club logo

Comments (6)

StephinChou avatar StephinChou commented on June 11, 2024

另外,填充逻辑似乎只支持一个类,如果有多种填充逻辑是需要自己在 一个类里进行区分实现吗?

from mybatis-plus.

miemieYaho avatar miemieYaho commented on June 11, 2024

ognl知道吧,ognl得到最终sql之后才会走填充,另外什么一个类八个类的,你要区分什么说清楚

from mybatis-plus.

StephinChou avatar StephinChou commented on June 11, 2024

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.

miemieYaho avatar miemieYaho commented on June 11, 2024

就这样的啊,有什么问题?

from mybatis-plus.

StephinChou avatar StephinChou commented on June 11, 2024

就这样的啊,有什么问题?

就是想确认下有没有更优雅的方案而已。 那这第二个问题结了。

主要还是想确认下这个。

@TableField(fill=INSERT_UPDATE) 我只要在实体类的任意一个字段注解, 然后在handle里写字段注入逻辑就可以了。

所以感觉fill这个属性应该是注解到 Table层面, 而不是字段层面

from mybatis-plus.

86jkuncle avatar 86jkuncle commented on June 11, 2024

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);    
}ifobj.getOriginalObject() instance of A) { setFieldValByName(“updateUser”, getUser(), metaObject); } else ifobj.getOriginalObject() instance of A) { setFieldValByName(“updateTime”, new Date(), metaObject); }

用这样的写法,而不能在 @TableField 指定我应该使用哪个填充逻辑
请问你的getUser()方法哪来的。。

from mybatis-plus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.