Grails Query, How to get a specific field in the result?
-
24-07-2021 - |
Frage
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" ])
Lösung
Product.findAllByNameIlike("%$params.name%",[order: "desc" ])?.collect{it.name}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow