ProductViewerController.groovy
class ProductViewerController {
def index(Integer id) {
def result=ProductLoader.createCriteria().list {
eq("product_barcode",id)
}
result.each {
notes->println "${notes}"
}
render(view:'index.gsp')
}
}
ProductLoader.groovy(模型类)
class ProductLoader { String store double price String notes static belongsTo =[product_barcode : Product] static constraints = { store() price() notes() } }
答案 0 :(得分:1)
需要将属性product_barcode
与对象类型Product
def result = ProductLoader.createCriteria().list {
eq("product_barcode", Product.get(id))
}
或者您加入外国表格,如
def result = ProductLoader.createCriteria().list {
product_barcode {
eq("id", id)
}
}