Pergunta

Recently I upgraded grails from 1.3.4 to 2.2.2 and I'm getting following error while trying to iterate over a Set defined as hasMany in a domain.

class A {
 String name
 static hasMany = [bList: B]
}

class B {
 static belongsTo = [a:A]
}

class TestController {
 def test = {
  A a = A.get(1L)
  def bList = a.bList
  bList.each{}
 }
}

Above line bList.each {} is throwing following exception

java.lang.IllegalArgumentException: wrong number of arguments

at org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener.onApplicationEvent(AbstractPersistenceEventListener.java:46)

at com.test.TestController$_closure2.doCall(TestController.groovy:5)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)

at java.lang.Thread.run(Thread.java:680)

Foi útil?

Solução

So I found the issue

Class B had a afterLoad() event hook attached to it which for some weird reason was throwing java.lang.IllegalArgumentException: wrong number of arguments exception I have now changed it to onLoad() Happy Days Now.

Thanks Hussain

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top