Reputation: 55
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
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
Reputation: 19682
You can use and
and ne
for:
createCriteria.list {
and {
ne 'value', 0
ne 'letter', 'A'
}
}
Upvotes: 2
Reputation: 13792
try "ne", not - equal
createCriteria.list{
and{
eq('value',0)
ne('letter','A')
}
}
Upvotes: 0