I have the following statement in grails 2.0.3 that works fine The
query I want to change by criteria
def result = db.rows('SELECT a.description FROM public."Description" as a ' +
'INNER JOIN public."product" as b ' +
'ON a.product_code = b.product_code ' +
'WHERE a.product_code = ?',[productInstance.product_code])
Cuase instead returns a description: [description], it returns a description: [description_fielddb: description]

Now in the controller, I tried to replace the following criteria:
List result = Description.withCriteria{
product{
eq('product_code', productInstance.product_code)
}
projections{
property('description')
}
}
but the product does not seem to have access:

Description.groovy
class Description {
String product_code;
String description;
static belongsTo = [product : Product]
static constraints = {
product_code blank:false, size: 1..15
description blank:false, size: 1..16
}
}
Product.grovy
class Product {
String store
String product_code
int price
String notes
static hasOne = [description: Description]
static constraints = {
product_code blank:false, size: 1..15
price blank:false, scale: 2
store blank:false, size: 1..40
notes blank:true , size: 1..150
}
product_code blank:false, size: 1..15
price blank:false, scale: 2
store blank:false, size: 1..40
notes blank:true , size: 1..150
}
}
I tried grails cleanand
grails compile --refresh-dependencies
I tried to remove the project from the package and import again