我是新來的Grails,並且遇到了一些查詢問題。我有兩個領域類是這樣的:如何創建自定義的Grails查詢
class Cliente {
String nombre
String cuit
String localidad
String establecimiento
static hasMany = [facturas: Factura]
}
class Factura {
String Proveedor
int sucursal
String numero
String letraFactura
Cliente cliente
Date fecha
String tipo
}
我想列出facturas
與客戶名稱的所有元素:
結果預計:
Proveedor|sucursal|numero|cliente_nombre|fecha
我已經嘗試了一些不同的方法,但始終得到cliente_id
不是cliente_nombre
。
這有點不清楚你的目標是什麼;你想要一個包含查詢返回給定字段的地圖嗎?爲什麼當您搜索時,facturas列表需要客戶名稱? – tylerwal
@tylerwal我想選擇Factura表中的所有項目,但用cliente_name替換cliente_id。在MySQL中,我會在Factura和Cliente之間加入一個聯盟。我希望我能更清楚一點。 – ConejoNegro
@ConejoNegro把你的問題澄清,即編輯你的問題。 – jogo