Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate grails executeQuery HQL-找不到参数_Hibernate_Grails_Hql_Gorm - Fatal编程技术网

Hibernate grails executeQuery HQL-找不到参数

Hibernate grails executeQuery HQL-找不到参数,hibernate,grails,hql,gorm,Hibernate,Grails,Hql,Gorm,我很少在查询中使用executeQuery,因为有时我会遇到此错误,但我不知道如何修复它,以下是我的代码: use(TimeCategory) { def referenceDate = new Date() - 101.year println '============================= '+referenceDate def cancelledSlots = RegistrantTestingCenterExamSch

我很少在查询中使用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:referencedate])它成功了。我真的不知道为什么我仍然会出现这个错误,似乎我正确地声明了参数,传递的值参数是有效的,因为我可以看到它打印在我的终端上。提前感谢。

根据(请参阅多行查询部分)三引号多行字符串将不能与HQL一起工作。请尝试使用换行符:

executeQuery("select rt.registrant.emailAddress \
from RegistrantTestingCenterExamSchedule as rt \
.... \
or rt.registrant.birthDate >= :refDate", [refDate : referenceDate])

应该可以。如果添加一个空格“
=:refDate
”,该怎么办?