| Author |
Using timestamp to prevent 'dirty data'
|
Song Jing Lim
Ranch Hand
Joined: Feb 11, 2003
Posts: 56
|
|
Hi... To prevent 'dirty data' as show below: User1 View RecNo1 User2 Del RecNo1 User3 Add new record (as RecNo will be reuse, user 3 will use back RecNo1 for difference data) Back to user1 he decide to edit/delete the RecNo1 after view... Problem came as the RecNo1 expected by User1 are not the one in database now. To prevent that problem, I will using timestamp as below: - Read the database during system startup and build a hashtable contain recNo and assign each with a timestamp value. - When user get the Record (will return as JavaBean object), timestamp associate with that recNo (from hashtable) will be set. - That timestamp will be use to compare the current timestamp associate wit h that record during edit/delete. There for: User1 View RecNo1 (current db, RecNo1 have timestamp x) User2 Del RecNo1 (current db, RecNo1 had remove) User3 Add new record (as RecNo will be reuse, user 3 will use back RecNo1 for difference data) (current db, RecNo1 have timestamp y) so when User1 want to edit/delete, system will alert user that timestamp in the object are difference from database. My approach is ok? Anyone have a better suggestion or alternative approach? Note: I using service side locking as lock() method implement didn't return any value (it is void), so not able implement client side locking. :roll:
|
Rgds,<br />Song Jing
|
 |
Roy Mallard
Ranch Hand
Joined: Jul 14, 2005
Posts: 53
|
|
I am using timestamps for this and it works fine.
|
SCJP 1.4<br />SCJD
|
 |
Song Jing Lim
Ranch Hand
Joined: Feb 11, 2003
Posts: 56
|
|
|
Thanks for reply, make me more confidence on that.
|
 |
 |
|
|
subject: Using timestamp to prevent 'dirty data'
|
|
|