Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

locking and unlocking mechanism

 
Joseph Tsui
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to implement a client program that can obtain record from MSSQL. I am using hibernate to do that.

So client A and client B will get record from DB server
both client A and B are on different machines

How can i prevent the situation that

ClientA get
ClientB get
ClientA update
ClientB update

In the database, i have a retrieve flag for each record. once the client get the record, it will update the record with the retrieve flag = true

Anyone can provide me advice on that? thanks a million
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a google (or a search in these forums) for "optimistic locking" - this is techique usually used to solve the lost update problem. Also, have a read of the Hibernate documentation about versioning, which is Hibernate's optimistic locking implementation.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic