我很少在查询中使用executeQuery,因为有时我会收到此错误并且我不知道如何修复它,这是我的代码:
use(TimeCategory) {
def referenceDate = new Date() - 101.year
println '============================= '+referenceDate
def cancelledSlots = RegistrantTestingCenterExamSchedule.executeQuery("""select rt.registrant.emailAddress from RegistrantTestingCenterExamSchedule as rt
where rt.registrant.firstName in(select i.firstName from Individual i) and rt.registrant.lastName in(select i.lastName from Individual i) and
rt.registrant.middleName in(select i.middleName from Individual i) and rt.registrant.birthDate in(select i.birthDate from Individual i) or
rt.registrant.seniorCitizen = false or rt.registrant.birthDate >=:refDate""",[refDate: referenceDate])
}
我收到此错误消息: 找不到命名参数 [refDate] 我试图删除不需要将其与声明的参数进行比较的条件(和 rt.registrant.birthDate>=:refdate",[refDate:refereneceDate] ) 并且它有效。我真的不知道为什么我仍然收到此错误,似乎我正确声明了参数,并且传递的值参数是有效的,因为我可以看到它打印在我的终端上。提前谢谢。