grails autocommit firing update queries when the position of elements is changed in the list

StackOverflow https://stackoverflow.com/questions/13325560

  •  28-11-2021
  •  | 
  •  

문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top