Patent ID: 7702658

Claim:
A computer implemented method for providing optimistic locking in a database containing a plurality of data records, comprising: providing a variable optimistic locking value for each data record; providing an optimistic locking programming class; during a database transaction, creating an optimistic locking instance of the optimistic locking programming class for a selected data record, the optimistic locking instance including: (i) a value property corresponding to a current value of the optimistic locking value for the selected data record; (ii) a property indicating whether the value of the optimistic locking value for the selected data record has been changed during the database transaction; (iii) a database operation clause fragment procedure for returning a database operation clause fragment based on the value property of the optimistic locking instance, wherein when the optimistic locking value for the selected data record has been changed during the database transaction the database operation clause fragment procedure returns an empty string; and (iv) a set current value procedure for setting the current value of the optimistic locking value for the selected data record from a result set of a SELECT operation that includes the optimistic locking value for the selected data record from the database; preparing a database operation SELECT statement for the selected data record, wherein the prepared database operation SELECT statement includes a database operation statement parameter clause including the database operation clause fragment returned by the optimistic locking instance for the selected data record; executing the prepared database operation SELECT statement resulting in a result set; determining whether the result set is empty; when the result set is not empty, calling the set current value procedure; when the result set is empty, determining whether the database operation clause fragment procedure returned an empty string; and when the database operation clause fragment procedure did not return an empty string, throwing an exception.