【问题标题】:What could the reason of the exception 'org.hibernate.QueryException Message Not all named parameters have been set:' possibly be?异常“org.hibernate.QueryException Message Not all named parameters have been set:”的原因可能是什么?
【发布时间】:2014-08-18 09:27:59
【问题描述】:

所以我试图在 grails 中执行以下查询

User user = springSecurityService.currentUser
def approverGroupList = approverGroupService.getApproverGroupsByUser(user.id)
return VerificationRequest.executeQuery("select distinct v.fundTransfer from VerificationRequest v where v.fundTransfer.creator.corporateHouse=:corporateHouse and v.verified = false and v.fundTransfer.status ='QUEUED' and v.approverGroup in (:approverGroupList)", [corporateHouse:corporateHouse],[approverGroupList:approverGroupList])

但是我得到以下异常:

/fund-transfer/list-verification-requests
Class
    org.hibernate.QueryException
Message
    Not all named parameters have been set: [approverGroupList] [select distinct v.fundTransfer from VerificationRequest v where v.fundTransfer.creator.corporateHouse=:corporateHouse and v.verified = false and v.fundTransfer.status ='QUEUED' and v.approverGroup in (:approverGroupList)]

corporateHouse 也是一个传递给执行此查询的方法的对象,它不为空。 可能是什么原因?

附:我是 grails 新手!

【问题讨论】:

  • 让我猜猜:没有设置所有参数?

标签: java hibernate grails


【解决方案1】:

您已将两张地图传递给executeQuery:

VerificationRequest.executeQuery("...", [corporateHouse:corporateHouse],[approverGroupList:approverGroupList])

应该是一张有两个值的地图:

VerificationRequest.executeQuery("...", [corporateHouse:corporateHouse, approverGroupList:approverGroupList])

根据documentation,第二张地图被视为带有附加参数的地图。

【讨论】:

    【解决方案2】:

    Looks like 参数应该在 one 映射中,像这样:

    [corporateHouse:corporateHouse, approverGroupList:approverGroupList]
    

    【讨论】:

      【解决方案3】:

      表示你还没有设置查询中的所有参数。你错过了一些检查你的查询执行代码

      【讨论】:

      • 你能指出哪里吗?老实说,我认为没有错误!但是,我当然对 grails 完全陌生!
      猜你喜欢
      • 2011-01-20
      • 2019-07-03
      • 2012-02-26
      • 1970-01-01
      • 1970-01-01
      • 2010-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多