title: efficient way to do bulk updates where values are assigned serially from a list?
body: <p>Lets say there is a domain A with property p. </p>
  
  <pre><code>class A{
   Integer p
  }
  </code></pre>
  
  <p>I have a list of A i.e </p>
  
  <pre><code>def lis = A.list()
  </code></pre>
  
  <p>and then i have a list of numbers</p>
  
  <pre><code>def num = [4, 1, 22, ......]
  </code></pre>
  
  <p>what is the most efficient way to do bulk update in grails where each object of A is assigned a number from num serially. </p>
  
  <p>One way could be</p>
  
  <pre><code>for(int i=0; i&lt;lis.size(); i++){
    lis[i].p = num[i]
    lis[i].save(flush: true)
  }
  </code></pre>
  
  <p>But this solution i assume is not efficient. Can this be achieved using HQL or other efficient methods? I appreciate any help! Thanks!</p>