0
我有以下的域對象創建格姆查詢JSON字符串列表
class ProductQuantity implements Comparable {
static constraints = {
}
Integer quantity
static mapping = {
version false
}
static belongsTo = Product
static hasMany = [products:Product]
int compareTo(obj) {
quantity.compareTo(obj.quantity)
}
}
我想返回一個JSON字符串,看起來像這樣[50,100,200]
隨着格姆,是有沒有去很容易做到這一點,而不必循環對象並創建一個集合?
我開始在這裏
def availableQuantities = ProductQuantity.findAll()
有什麼建議?
toString是我所需要的,謝謝 –