db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <tfisc...@apache.org>
Subject Versioning in Torque (was: AW: torque vs hibernate)
Date Sun, 15 Apr 2007 09:52:32 GMT
On Sat, 7 Apr 2007, Thoralf Rickert wrote:
>>> 3)Torque does not contain built-in help for version checking. As a
>>> result, this feature will require a custom implementation for future
>>> enhancements.
>> I do not understand what that means. Could you explain what they mean by
>> "version checkin"? An example would be great.
> I think they mean something like update verification. If you select a
> row into an object and save this object the mapper should/could verify
> if the row in the database hasn't change. You could use a
> "last-modification"-timestamp field or a counter-field, that is set in
> every successful UPDATE execution (trigger). I'm not sure if Hibernate
> has "build-in-support" for this, but it's easy to implement in Torque.
Your explanation of the term makes sense. This was known to me as 
"optimistic locking". I have actually implemented it for a project, and it 
is relatively easy to do. The basic idea is to use triggers to 
increase a counting column each time a row is saved, and to check 
this column against the provided value when an update comes in. If 
the provided number does not match the one in the database, the 
trigger throws an error.
However, there are a few points to remember:
- The counting column needs to be updated in the save() method of the java 
object accordingly to allow subsequent saves. When doing this, the 
modified property of the object must not be changed, otherwise an update 
occurs on every save() and not only if the object has changed.
  - If one uses Sarav's patched village lib for oracle and use blobs and 
clobs, the patched lib needs to be patched again.


To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org

View raw message