Hi All, I have a scenario as below Please help me out to implement this ;-)
------------------- Scenario ------------------- 1> 2 users are accessing a single record (in a web based J2EE App) at the same time 2> 1 user should be able to see one of the records in READ ONLY MODE and the other user in WRITE ONLY MODE
Assuming 1st user access's 1st Record hence RECORD1.WRITE_ONLY_MODE -- EDITABLE
Assuming 2nd user access's 1st Record hence should be RECORD1.READ_ONLY_MODE -- NON EDITABLE
3> When the 1st user is accessing the 1st record,He enters the details of the 1st record,and clicks on "save button",The data gets saved to the db. ;When the 2nd user access the 1st record at the same instance of time,he should be displayed with a message saying " RECORD IS LOCKED BY ANOTHER USER,Trying Accessing After Sometime"
5>The 1st user after saving the data for 1st record comes out of the record profile.now if the 2nd user tries to "REFRESH" The Jsp page and tries to access the same 1st RECORD ,He should be displayed with the message "RECORD IS AVAILABLE FOR CHANGES."
How do i go about in implementing this in a J2EE Web based application.
IN CASE IF U KNOW THE IMPLEMENTATION LOGIC.PLEASE PROVIDE THE SAME
What persistence framework are you using? Hibernate, JDBC, etc. Read up on the database isolation levels and ACID properties. If you are using Hibernate, you can use its optimistic locking strategy. Also have a look at "select for update ...." [ September 20, 2008: Message edited by: arulk pillai ]
I think what this interview/assignment question is trying to get you to talk about is locking strategies. In which case arulk pillai has already mentioned one, and hinted at another. I'd have a google for them and see what you learn, or alternatively try searching this forum.
Originally posted by arulk pillai: What persistence framework are you using? Hibernate, JDBC, etc. Read up on the database isolation levels and ACID properties. If you are using Hibernate, you can use its optimistic locking strategy. Also have a look at "select for update ...."
[ September 20, 2008: Message edited by: arulk pillai ]
Have a google for the highlighted terms. [ September 22, 2008: Message edited by: Paul Sturrock ]