Grails Query, How to get a specific field in the result?
-
24-07-2021 - |
Question
I have the domain class:
class Product {
String barcode
String name
String measurement
static constraints = {
}
}
Now, I want to get a list with only one field like "name":
Product.findAllByNameIlike("%$params.name%",[order: "desc" ])
La solution
Product.findAllByNameIlike("%$params.name%",[order: "desc" ])?.collect{it.name}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow