【发布时间】:2016-01-06 09:32:09
【问题描述】:
使用 grails 2.1.1,我需要使用左连接构建一个包含 2 个表的查询。如果我在 oracle 中查询它,它正在工作并给我正确的结果。当我使用 grails 控制器时,出现错误。谁能帮我解决这个问题?
以下是我的尝试:
我在 oracle 上的查询:
SELECT MS.* FROM
SLS_DO_MST MS LEFT OUTER JOIN INV_ISSUE ISS
ON MS.MID = ISS.SLS_DO_MST_MID
where ISS.SLS_DO_MST_MID is null
我在 grails 控制器中使用的 hql 查询:
def items = SlsDoMst.executeQuery('select a from sls.dlo.SlsDoMst a left outer join inv.InvIssue b on a.id = b.slsDoMst.id where b.slsDoMst.id is null')
我得到的错误:
unexpected token: on near line 1, column 66 [select a from sls.dlo.SlsDoMst a left outer join inv.InvIssue b on a.id = b.slsDoMst.id where b.slsDoMst.id is null]
我的域名如下::
我的 SlsDoMst 域 >>>
class SlsDoMst {
...
static mapping = {
...
}
static constraints = {
...
}
}
我的 InvIssue 域 >>>
class InvIssue{
static mapping = {
table 'INV_ISSUE'
slsDoMst column: 'SLS_DO_MST_MID',ignoreNotFound: true
...
}
...
SlsDoMst slsDoMst
static constraints = {
...
}
}
【问题讨论】:
标签: hibernate grails grails-orm grails-2.0 hibernate-criteria