GithubHelp home page GithubHelp logo

Comments (5)

itfsw avatar itfsw commented on May 27, 2024

我没有怎么听懂你说的意思?
1.你的意思是list为empty的时候查询结果返回空?那为什么还要进查询呢,直接在代码里判断然后进行后续效率不是更高而且代码可读性更强?
2.还是说你是想实现如果list为empty就不加这个条件?这样你可以配合ExampleEnhancedPlugin插件这样写

userMapper.selectByExample(
        new UserExample()
                .createCriteria()
                .andIf(!CollectionUtils.isEmpty(userIds), add -> add.andUserIdIn(userIds))
                .example()
);

from mybatis-generator-plugin.

swellwu avatar swellwu commented on May 27, 2024

from mybatis-generator-plugin.

itfsw avatar itfsw commented on May 27, 2024

一般这种属于输入数据的异常了,如果是我处理可能会去使用验证框架,然后捕获验证异常,对于这些数据封装一个合理的返回吧。

from mybatis-generator-plugin.

swellwu avatar swellwu commented on May 27, 2024

也不是输入数据异常,就是涉及到多张表的搜索查询,每一个查询都会过滤,然后留下一个list来in,当查询条件比较多时,会出现多个是否为空的判断。

from mybatis-generator-plugin.

itfsw avatar itfsw commented on May 27, 2024

这个已经进入方法内部逻辑实现了,也不可能在做切面之类的,可能只能通过一系列的判断来过滤了。虽然可以重写Criterion之类的来生成一些反向sql来实现你所描述的功能,但这毕竟会进入sql执行,效率肯定就比不上你外层的if判断了。目前好像也没有特别好的处理方式。

from mybatis-generator-plugin.

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.