Grails where clause, why cant i search where id == id? - grails

This has been bothering me for a bit. The following query works:
Receipt.where{project.customer == customer}.list()
but this query throws an exception
Receipt.where{project.customer.id==customer.id}.list()
exception:
Class
groovy.lang.MissingMethodException Message
No signature of method: receiptbucketserver.Customer.call() is applicable for argument types:
(receiptbucketserver.ReceiptHelperService$_tt__getReceiptsByCustomer_closure11_closure12_closure13)
values:
[receiptbucketserver.ReceiptHelperService$_tt__getReceiptsByCustomer_closure11_closure12_closure13#170130c3]
Possible solutions: wait(), last(), save(), any(), getAll(),
wait(long)

Related

Jenkins/Groovy: How to pass named parameters and closures to the same method?

I have a shared library method with this signature:
call(Map kwargs, String image_name, String version, Closure closure)
And I'm calling it like so:
dockerBuildWith("go-build", "latest", image_context: "build",
changesets: ["build/Dockerfile"]) {
...
}
But I'm getting this error:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: dockerBuildWith.call() is applicable for argument types: (java.util.LinkedHashMap, java.lang.String, java.lang.String, org.jenkinsci.plugins.workflow.cps.CpsClosure2) values: [[image_context:build, changesets:[build/Dockerfile]], go-build, ...]
Possible solutions: call(java.lang.String, java.lang.String, groovy.lang.Closure), wait(), any(), run(), run(), dump()
I forgot to put def in front of the call() definition.

Loop through each entity of a domain class in a service

I have a domain class called StatusReport. I also have a service called StatusReportsService.
Grails documentation gives examples like:
Book.list().each{}
However I get an error when I use:
StatusReport.list().each{}
Which gives me the error
Message: No signature of method: static com.tr.StatusReport.list() is applicable for argument types: () values: []
Possible solutions: is(java.lang.Object), wait(), find(), wait(long), print(java.io.PrintWriter), find(groovy.lang.Closure)
How can I loop through each domain entity in a service?

grails test-app integration coverage giving error

My code
def baseRecordList = DealerBaseInfo.findAll("from DealerBaseInfo as dealers",[cache: false])
is giving the below error inside PriorApprovalController.groovy
groovy.lang.MissingMethodException: No signature of method: DealerBaseInfo.findAll() is applicable for argument types: () values: []
Possible solutions: findAll(), findAll(), findAll(groovy.lang.Closure), findAll(java.lang.Object), findAll(java.lang.String), findAll(groovy.lang.Closure)
at DealerBaseInfo.findAll(DealerBaseInfo.groovy)
at DealerBaseInfo$findAll.call(Unknown Source)
PriorApprovalController.<init>(PriorApprovalController.groovy:37)
... 42 more
| Error Exception occurred trigger event [TestPhasesEnd]: Could not create a new instance of class [PriorApprovalController]!`
grails version is 2.1.1 and code-coverage plugin 1.2.5
Why is that and how do I fix it?
Have a look at the findAll() supported signatures: http://grails.org/doc/2.1.0/ref/Domain%20Classes/findAll.html
To use the queryParams, I think you should do something like this:
def baseRecordList = DealerBaseInfo.findAll("from DealerBaseInfo as dealers", [], [cache: false])
actually the error was coming because of class level access of findAll method i have written a static method in domain for findAll and access that method in controller then it worked

Grails: getAll throwing no signature of method exception?

According to the Grails literature
http://grails.org/doc/2.0.x/ref/Domain%20Classes/getAll.html
I should be able to do this
def biweeklyBatchRanges = BiweeklyBatchRange.getAll()
without getting this
groovy.lang.MissingMethodException: No signature of method: com.myplang.donation.BiweeklyBatchRange.getAll() is applicable for argument types: () values: []
Possible solutions: getAll(), getAt(java.lang.String), getId(), get(java.io.Serializable), getClass(), findAll()
Any ideas? TIA!
Never got an "answer" to this, except to use findAll. (Grails 2.0.3)

Grails session cannot assign java.string

I'm getting this error
Error 500: Executing action [pay] of controller [org.gamestrike.PaymentController] caused exception: groovy.lang.MissingMethodException: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Servlet: grails
URI: /GameStrike/grails/payment/pay.dispatch
Exception Message: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Caused by: No signature of method: org.gamestrike.PaymentController.session() is applicable for argument types: (java.lang.String) values: [2011-09-15] Possible solutions: getSession()
Class: PaymentController
At Line: [35]
Code Snippet:
Without your code it's hard to tell, but it looks like you're treating session like a method, but it's not. It's an object - the HttpSession instance.
You can call the standard methods on it, e.g. getAttribute and setAttribute but Grails adds convenience behavior. It acts like a Map so to set or get attributes you can do this:
def foo = session.foo // session.getAttribute('foo')
session.bar = 123 // session..setAttribute('bar', 123)

Resources