ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mule_user <s...@aol.com>
Subject IBATIS 2.3.3, JDK 1.5 - Optimistic locking strategies
Date Tue, 07 Oct 2008 21:44:18 GMT

I would like to explore the strategies for achieving optimistic locking using
iBATIS 2.3.3 and JDK 1.5.

Following are the constraints:
1. Need to use timestamp column in the database. Cannot use version column
in the database, as the current data model does not support version.
2. It will be possible to achieve optimistic locking using timestamp, if I
keep "OldObject" in scope and write SQL similar to:

update TABLE1
set COL1 = 'valueFromNewObject'
where ID = idOfOldObject
and timestamp = timestampOfOldObject;

This approach requires keeping "OldObject" in scope. "OldObject" may be
available either in program scope, or can be looked up from cache. 

That being said, I would like to ask the following questions:

1. Will it be possible to use cache model of iBatis to keep "OldObject" in
scope? In that way, me as an application developer will not have to write
any code. Caching in iBatis looks like:

<cacheModel id="product-cache" implementation="LRU">

If iBatis cache can be used to keep "OldObject" in scope, please show
example on how I can look up  the "OldObject" from the cache model of
iBatis. 

2. Please show how I can extend the cacheModel of iBatis to use other cache
e.g. ehcache. 

3. Is it a good idea to extend the cache model of iBatis to ehcache? Or,
should the cache model of iBatis be used for looking up "OldObject"?

4. Is there another way to achieve optimistic locking using timestamp,
without looking up the "OldObject" available from the program scope, or from
the cache? 

5. Please refer me to any other articles, readings, or example code. 
-- 
View this message in context: http://www.nabble.com/IBATIS-2.3.3%2C-JDK-1.5---Optimistic-locking-strategies-tp19867989p19867989.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message