简体   繁体   English

GRAILS:createCriteria NAND

[英]GRAILS: createCriteria NAND

I have a bunch of rows from my query in createCriteria, but some changes have to be made, I need to hide the rows with a 0 in a column and a letter A in other column, but i won't hide them if they have 0 and another letter , how can I make this in createCriteria? 我在createCriteria中查询了一堆行,但是必须进行一些更改,我需要隐藏列中的0和其他列中的字母A的行,但如果他们有,我不会隐藏它们0和另一个字母,我怎么能在createCriteria中做到这一点? my only solution is using a NAND, but it doesn't exist I think... 我唯一的解决方案是使用NAND,但我认为它不存在......

             createCriteria.list{
                     nand{
                          eq('value',0)
                          eq('letter','A')  
                     }
             }


             TABLE
             VALUE          LETTER
             0              A                HIDE
             0              B                NOT HIDE
             1              A                NOT HIDE

any suggestion? 有什么建议吗?

You can use and and ne for: 您可以使用andne为:

createCriteria.list {
    and {
        ne 'value', 0
        ne 'letter', 'A'
    }
}

try "ne", not - equal 尝试“ne”,不是 - 相等

createCriteria.list{
   and{
      eq('value',0)
      ne('letter','A')  
   }
}

Using HQL you can do: 使用HQL,您可以:

def result = Object.executeQuery(
   "from Object o where o not in " +
       "(from Object o2 where o2.value = '0' and o2.letter = 'A')",
  )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM