Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using timestamp to prevent 'dirty data'

 
Song Jing Lim
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Roy Mallard
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using timestamps for this and it works fine.
 
Song Jing Lim
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply, make me more confidence on that.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic