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

How solve this scenario?

 
Firoz navrang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have one scenario and that could solve by Java.

UserA is updating a record into db, but at the same time UserB wants to check the old recored from the same db. If a userA updated a record, then how can a userB can see the old record, because the old record is overwrited in the db.

This can be solve with Java or J2EE.

Help would be appricaite.

Thanks
Gaju
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set your translation isolation to allow dirty reads, but I don't think this is your question.

If you want both the old and new data to be available, you need to manage that yourself, such as inserting a new value then anly allowing A to see the latest value but allowing B to see all historical values.
 
Rejeev Divakaran
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he is looking for 'read-committed'. If you use read commited concurrncy level. B will see old value untill A commit the transaction. If you want B to see old values even after A commits then you need to manage yourself.
 
Firoz navrang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Still, I am not clear about the scenario. Can you please eloborate bit more, and if you have any example similar to that, I really appriciate.

Thanks

Fyrose
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the transaction that updated the record has committed, then your only option is to implement some sort of history table mechanism in your model. By this you use a trigger to copy data from your main table to a history table before any update is made. Is this the sort of thing you are looking for?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic