i can do this:
def criteria = Category.createCriteria();
def results = criteria.list{
like('categoryName', "%abc%") or
like('categoryName', "%qwe%")
};
but how i do it for unknown number of string values? i would like do something like:
def results = criteria.list{
for (str in strList){
like('categoryName', str) or
}
};
but ofcourse it doesnt work.
Use or { }
:
def criteria = Category.createCriteria()
def results = criteria.list {
or {
strList.each { str ->
like('categoryName', "%${str}%")
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With