문제

I'm curious about best practice when it comes to updating a domain object that may be updated by multiple sessions.

The call that occurs is AJAX from the g:remoteField tag. It takes the value and updates a domain object:

            person.refresh()
            person.isLeader = true
            person.save(flush:true)

I added a refresh prior to the update, since the value could be different.

Is this the best way to handle this? Is there a better way to handle updating? I don't particularly care if two people update at the same time in this scenario.

도움이 되었습니까?

해결책

In general, I prefer to let the optimistic locking do it's job and override it where I explicitly don't care if users stomp on each others' changes. (Note: these cases are few and far between)

What this means for highly ajaxy sites is that you have to have very solid error handling to cover update conflicts.

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