Loop through each entity of a domain class in a service - grails

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?

Related

How to fix groovy.lang.MissingMethodException: No signature of method when calculating the total

I am trying to connect to Cassandra and write a query in Grails to total the amount but I am getting a missing method exception:
groovy.lang.MissingMethodException: No signature of method: project
.sampleTest.column() is applicable for argument types: (java.lang.String) values: [amount]
Possible solutions: collect(), dump(), collect(groovy.lang.Closure)
Below is the query what I have written to sum the amount.
Select selectQuery = QueryBuilder.select().fcall("sum", column("amount")).from(tableName).allowFiltering()
Session session = cassandraTemplate.getSession();
Where selectWhere = selectQuery.where();
To use a column name inside of fcall() you need to use the static method QueryBuilder.column(). So when you use it in fcall() you need to call it like:
Select selectQuery = QueryBuilder.select().fcall("sum", QueryBuilder.column("amount")).from(tableName).allowFiltering()

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

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)

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