FAQ Database Discussion Community

Check-and-set in Couchbase Java SDK 2.x?

In older version of Couchbase Java SDK there were several check-and-set (CAS) methods for implementing optimistic locking. But what is corresponding API in a newer version of SDK (>= 2.0)? Initial code: JsonDocument doc = bucket.get("myKey"); Long casValue = doc.cas(); // some method to set new value for "myKey" only...

Should the natural or surrogate key be returned in an API?

First time I think about it... Until now, I always used the natural key in my API. For example, a REST API allowing to deal with entities, the URL would be like /entities/{id} where id is a natural key known to the user (the ID is passed to the POST...

optimistic lock with a “version” field vs snapshot isolation level

I was wondering what are the advantage/inconvenient for these two optimistic lock solutions : Use a "version" field and detect changes during updates (i.e. using hibernate @Version annotation) Use the Snapshot isolation level on transactions If I'm correct these 2 solutions have the same behavior : an error will be...

Rails - Optimistic locking always fires StaleObjectError exception

I'm learning rails, And read about optimistic lock. I've added lock_version column of type integer into my articles table. But now whenever I try to update a record for the first time, I get StaleObjectError exception. Here's my migration: class AddLockVersionToArticle < ActiveRecord::Migration def change add_column :articles, :lock_version, :integer end...

Spring MVC: Validation, Post-Redirect-Get, Partial Updates, Optimistic Concurrency, Field Security

How do I update only a few fields of a model entity with forms? How do I use the Post-Redirect-Get pattern with Spring MVC, especially with form validation? How do I secure certain fields in my entities? How do I implement Optimistic Concurrency Control?...

Getting timestamp from Objecify entity?

Is it possible to obtain the timestamp that is used for optimistic concurrency control from an Objectify entity (or a lower-level part of the Google Datastore infrastructure) and if so, how?