views:

131

answers:

1

Hi, should always the "version" field be checked when updating a domain class object ? If so, is using a while with sleep an acceptable option ?

+3  A: 

Why would you want to check the version? This is maintained automatically by hibernate for optimistic locking. i.e. if the version has changed since you loaded the object any update you flush to the DB will fail.

Normal Grails apps do not need to interact with the version property.

Marc Palmer
I checked the update actions in the "grails generate-all"-created controllers. There's special care in there if the version is 1. You can check it yourself.
xain
This is unnecessary in most applications. It is simply useful if you want to pre-empt any concurrent modification issues.You don't need to worry unless you have to deal with providing smarter handling of concurrent change situations.
Marc Palmer