Smrita
Smrita

Reputation: 1279

What could the reason of the exception 'org.hibernate.QueryException Message Not all named parameters have been set:' possibly be?

So I am trying to execute the following query in 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])

However I am getting the following exception :

/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)]

Also corporateHouse is an object that's passes to the method executing this query and its not null. What could be the reason?

P.S. I am new to grails!

Upvotes: 0

Views: 284

Answers (3)

Paweł Piecyk
Paweł Piecyk

Reputation: 2789

You've passed two maps to executeQuery:

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

It should be one map with two values:

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

According to documentation the second map was taken as map with additional parameters.

Upvotes: 4

cy3er
cy3er

Reputation: 1699

Looks like the parameters should be in one map, like this:

[corporateHouse:corporateHouse, approverGroupList:approverGroupList]

Upvotes: 4

Mohan Raj B
Mohan Raj B

Reputation: 1026

It means that you have not set all the parameters in the query. You have missed some check your query execution code

Upvotes: 0

Related Questions