![](/img/trans.png)
[英]In Grails using DataSourse I am trying to insert data but only id field is get save another field are save
[英]I try to get data from postgreySQL basis on criteria using grails and groovy but i am facing issue while accesing the list foregin key id
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() } }
需要將屬性product_barcode
與Product
的對象類型進行比較
def result = ProductLoader.createCriteria().list {
eq("product_barcode", Product.get(id))
}
或者你像這樣加入外國餐桌
def result = ProductLoader.createCriteria().list {
product_barcode {
eq("id", id)
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.