0

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? my only solution is using a NAND, but it doesn't exist I think...

             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?

user1698253
  • 55
  • 1
  • 7

3 Answers3

2

You can use and and ne for:

createCriteria.list {
    and {
        ne 'value', 0
        ne 'letter', 'A'
    }
}
doelleri
  • 19,232
  • 5
  • 61
  • 65
0

try "ne", not - equal

createCriteria.list{
   and{
      eq('value',0)
      ne('letter','A')  
   }
}
Miguel Prz
  • 13,718
  • 29
  • 42
0

Using HQL you can do:

def result = Object.executeQuery(
   "from Object o where o not in " +
       "(from Object o2 where o2.value = '0' and o2.letter = 'A')",
  )
Benoit Wickramarachi
  • 6,096
  • 5
  • 36
  • 46