title: Coerce result row into object
body: <p>Is there a way to coerce the result row gotten from calling a stored procedure into a specific object so I can pass just a list of that object into the view?</p>
  
  <p>I know I can use things like Node.list() to do this, but I am eventually going to replace getnodes() with a fairly complicated stored procedure that creates temp tables and does some optimised sql fu. But for now I am just working on the grails interaction.</p>
  
  <p>So on MySQL side I have the following stored procedure:</p>
  
  <pre><code>CREATE DEFINER=`root`@`255.255.255.255` PROCEDURE `getnodes`()
  BEGIN
     select * from node;
  END
  </code></pre>
  
  <p>On the grails controller I have the following:</p>
  
  <pre><code>def nodes = new ArrayList&lt;Node&gt;()
  
  // collect all the nodes returned
  sql.eachRow("{call getnodes()}") { 
      nodes.add(it as Node)
  }
  
  println "Nodes size is: " + nodes.size()
  nodes.eachWithIndex { d, i -&gt;
      println "$i : $d"
  }
  </code></pre>
  
  <p>My plan is to then pass the nodes to the view.</p>
  
  <p>The problem is that it blows up on the line:</p>
  
  <pre><code>nodes.add(it as Node)
  </code></pre>
  
  <p>Is this even possible? I mean this should just coerce right? What am I doing wrong?</p>