user1698253
user1698253

Reputation: 55

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? 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?

Upvotes: 0

Views: 146

Answers (3)

Benoit Wickramarachi
Benoit Wickramarachi

Reputation: 6226

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')",
  )

Upvotes: 0

doelleri
doelleri

Reputation: 19682

You can use and and ne for:

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

Upvotes: 2

Miguel Prz
Miguel Prz

Reputation: 13792

try "ne", not - equal

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

Upvotes: 0

Related Questions