I have scenario where i need to move an object to the begining of the array list.
Right now i have something like this
List a = [obj1, obj2, obj3, obj4, obj5, obj6, obj7]
now to move obj4 to the begining of the list i am removing it from the list like this
a.remove(obj4)
a.add(obj4)
and then reversing the collection
Collections.reverse(a);
when i am doing this, grails is automatically firing update query for some of the objects
another way which i have tried is i created a new list and then added elements like this
def b = []
b.add(obj4)
a.each{
b.add(it);
}
but in this case multiple update queries are getting fired, i am not at all touching the objects.
Please help me debug this
Alright i did lot of head banging and finally found a workaround for this, somehow the version(which grails provides by default) was getting updated and that's why it was firing update query, disabling the grails versioning solved the problem for me, hope that helps someone