Im new to grails and I try to get a database entry.
The database connection works without problems.
In the database Ive got a class named “Correct” which contains correct answers (booleans), so its structure is:
id | version | answera | … | answerh | lpicid
lpicid references to a question. for each lpicid there is only ONE entry. primary key is id.
Now when I want to call the correct answers and save the answers in variables, this doesnt really work:
def correctanswers = Correct.executeQuery("from Correct answers where answers.lpicid=" + lpicid);
def correcta = correctanswers.answera();
I get an database entry, I can see that (lpicid is just a def number), but correctanswers.answera() does not work. I always get this message:
groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.answera() is applicable for argument types: () values: []
Possible solutions: inspect(), clear(), clear(), clear(), any(), asList()
at com.lpic.LpicSimulatorController$_closure2.doCall(LpicSimulatorController.groovy:76)
at com.lpic.LpicSimulatorController$_closure2.doCall(LpicSimulatorController.groovy)
at java.lang.Thread.run(Thread.java:662)
How can I solve this in order to get the answera, answerb…. values?
thank you 🙂
If you can use id directly then the easiest and most efficient ways is to call
Correct.get(id).Otherwise look into the
findBydynamic domain method.