title: Missing addTo Method
body: <p>I am attempting to use the <code>addTo*</code> method in Grails one class to another. These classes have a many to many relationship. I have defined the <code>hasMany</code> in the first class..</p>
  
  <pre><code>static hasMany = [operators: Operator]
  </code></pre>
  
  <p>And have done the same in the other:</p>
  
  <pre><code>static hasMany = [matches: MatchDB]
  </code></pre>
  
  <p>And I have set the owner of the relationship:</p>
  
  <pre><code>static belongsTo = MatchDB
  </code></pre>
  
  <p>However, when I attempt to access <code>addToOperators</code>, as follows:</p>
  
  <pre><code>def matchDBInstance = MatchDB.get(result.matchId);
  Operator operatorInstance = Operator.get(result.operatorId);
  matchDBInstance.addToOperators(operatorInstance);
  matchDBInstance.save(flush: true);
  </code></pre>
  
  <p>I am seeing the following error:</p>
  
  <pre><code>groovy.lang.MissingMethodException: No signature of method: footballservices.MatchDB.addToOperators() is applicable for argument types:   (footballservices.Operator) values: [footballservices.Operator : Op1]
  Possible solutions: getOperators()
  at footballservices.RestfulController.mapOperator(RestfulController.groovy:63)
  at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198)
  at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63)
  at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
  at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
  at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
  at com.brandseye.cors.CorsFilter.doFilter(CorsFilter.java:82)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  at java.lang.Thread.run(Thread.java:724)
  </code></pre>
  
  <p><strong>I have tried..</strong></p>
  
  <p>I've spent some time trawling through the internet. I have ran <code>grails clean</code>, which didn't help. I have also attempted to add:</p>
  
  <pre><code>List&lt;Operator&gt; operators;
  </code></pre>
  
  <p>to the <code>MatchDB</code> class, but this didn't do anything either.</p>
  
  <p>I have verfiied that both <code>matchDBInstance</code> and <code>operatorInstance</code> are not null.</p>
  
  <p><strong>Details</strong></p>
  
  <p>I am running Grails 2.4.3, JDK 7 on a Windows 7 machine.</p>