由于我之前的问题没有得到解答,我想再问一次。
高品质
from Agenda agr
inner join agr.agenda a with a.employee.id = :employeeId
left join agr.employer wgr
left join wgr.contracts cnt with agr.date >= cnt.validFrom and agr.date < cnt.ValidUntil
我收到了消息
with-clause referenced two different from-clause elements
native SQL
left join contract cnt
on agr.wgv_id = cnt.wgv_id
and agr.date >= cnt.validFrom
and agr.date < cnt.validTill
在上一个问题中,建议是使用 HQL 和 'with' 子句。这可能是一种方式吗?建议?
最佳答案
{替换}
如果您希望捕获空记录,则只需要左连接,否则只需使用连接
from Agenda agr
inner join agr.agenda a with a.employee.id = :employeeId
left join agr.employer wgr
left join wgr.contracts cnt
where agr.date >= :start
and agr.date <= :end
and ((agr.date >= cnt.validFrom and agr.date < cnt.validTill) or agr.employer is Null)
通缉
from Agenda agr
inner join agr.agenda a with a.employee.id = :employeeId
left join agr.employer wgr
left join wgr.contracts cnt with agr.date >=cnt.validFrom and agr.date < cnt.valifTill
where agr.date >= :start
and agr.date <= :end
关于带子句的 grails HQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32475219/