This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes How solve this scenario? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How solve this scenario?" Watch "How solve this scenario?" New topic

How solve this scenario?

Firoz navrang

Joined: Oct 18, 2007
Posts: 4
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.

David O'Meara

Joined: Mar 06, 2001
Posts: 13459

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

Joined: Aug 12, 2007
Posts: 27
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.

Regards,<br />Rejeev<br />Blog: <a href="" target="_blank" rel="nofollow"></a>
Firoz navrang

Joined: Oct 18, 2007
Posts: 4

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.


Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

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?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
I agree. Here's the link:
subject: How solve this scenario?
It's not a secret anymore!