【问题标题】:Ormlite change order of queryOrmlite 更改查询顺序
【发布时间】:2019-04-20 22:19:36
【问题描述】:

我在 orm lite 中创建了一个这样的查询:

TAbleA.queryBuilder()
                        .where()
                        .eq("col1", Wait)
                        .or()
                        .eq("col2", Fail)
                        .and()
                        .isNull("col3")
                        .or()
                        .le("col4", fromThisTime)
                        .prepare(); 

它准备这个查询:

MappedStatement: SELECT COUNT(*) FROM `TableA` WHERE (((`col1` = 'Wait' OR `col2` = 'Fail' ) AND `col3` IS NULL ) OR `col4` <= '2018-11-18 13:08:03.637000' ) 

但我想将其更改为:

MappedStatement: SELECT COUNT(*) FROM `TableA` WHERE (`col1` = 'Wait' OR `col2` = 'Fail' ) AND (`col3` IS NULL OR `col4` <= '2018-11-18 13:08:03.637000' ) 

我该怎么做?!

我想更改ANDOR 的顺序。

有人可以帮帮我吗?

【问题讨论】:

    标签: java android sqlite ormlite


    【解决方案1】:

    根据this,最简单的方法是:

    TAbleA.queryBuilder()
                        .where()
                        .eq("col1", Wait)
                        .eq("col2", Fail)
                        .or(2)
                        .isNull("col3")
                        .le("col4", fromThisTime)
                        .or(2)
                        .and(2)
                        .prepare(); 
    

    否则,您可以使用 post-order

    编写复杂的查询

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-24
      • 2014-01-08
      • 2016-05-09
      • 1970-01-01
      • 2013-11-19
      相关资源
      最近更新 更多