title: grails: findallbyidinlist method
body: <p>In my grails project, I've used the method <code>Object.findAllByIdInList()</code>, passing a list as parameter.
  The code used is the following:</p>
  
  <p><code>def allSelectedIds = ReceiptItem.findAllByIdInList(par)</code></p>
  
  <p>In which the ReceiptItem is a domain class defined as follows:</p>
  
  <pre><code>class Receipt {
      double totalAmount;
      Date releaseDate;
      int vatPercentage;
      int discount;
      Boolean isPayed;
      Boolean isInvoice;
      static belongsTo = [patient:Patient]
      static hasMany = [receiptItems:ReceiptItem]
  
      static constraints = {
          receiptItems(blank:  false)
          patient(blank: false)
          totalAmount(blank: false)
          vatPercentage(blank: false, nullable: false)
      }
  }
  </code></pre>
  
  <p>and <code>par</code> is the list of ids defined as follows:</p>
  
  <pre><code>def par = params.list("receiptItemsSelected")
  </code></pre>
  
  <p><code>receiptItemsSelected</code> is defined in the gsp page into the <code>remoteFunction()</code> as follows:</p>
  
  <pre><code>params: '\'receiptItemsSelected=\' + jQuery(this).val()'
  </code></pre>
  
  <p>The problem is that the line above throws the following exception:</p>
  
  <pre><code>java.lang.String cannot be cast to java.lang.Long. Stacktrace follows:
  Message: java.lang.String cannot be cast to java.lang.Long
  </code></pre>
  
  <p>I don't understand why it is throwing this exception.</p>
  
  <p>Thanks for your help</p>