我在 Grails 中有以下域模型,我试图对其运行查询,但它失败了,说它是一个无效的查询。
查询如下所示:
StringBuilder queryBuf = new StringBuilder(); queryBuf.append("select rr.role from ReportRole rr "); def newroles = ReportRole.findAll(queryBuf)
而且,域看起来像这样:
package auth
import java.util.Date
import auth.Report
import auth.Role
class ReportRole {
Long id
Report report
Role role
Date dateCreated
Date lastUpdated
Person createdBy
static mapping = {
table 'CIT_RM_Report_Role'
version false
role joinTable:[name:'AU_ROLE_DESCR', key:'role_id', column:'id']
columns {
id column:'report_role_id'
report column:'report_id'
createdBy column:'created_by'
dateCreated column:'create_date'
lastUpdated column:'last_updated'
}
}
}
package auth;
class Role {
static hasMany = [people: Person]
Long id;
String authority;
String description;
static mapping = {
table 'AU_ROLE_DESCR'
people joinTable:[name:'AU_PERSON_ROLE', key:'AUTHORITY_ID', column:'PERSON_ID']
version false;
}
}
谁能告诉我为什么这是无效的。我有一些类似的域,这样的查询可以工作。