Results 1 to 3 of 3

Thread: Conceptual Question Locking and Transactions Webapp

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    18

    Question Conceptual Question Locking and Transactions Webapp

    Hi Guys,

    I do have a conceptual question and don't know what to google/search for as I don't have any approach yet. Let me try to explain my problem by example.

    Imagine a full flavoured web application, using a database, hibernate for jpa, spring mvc, and a javascript/ajax/jsp frontend. Let's suppose the app is supposed to be a multi-user capable address book. If a user opens an address book entry in the browser the data get's fetched via ajax from a spring controller via service methods and daos. It's displayed in the browser such that a user can edit the record.

    Now imagine user Bob opens the record "Alice Smith, Park Avenue" on Monday. He leaves the browser open (let's also assume that there is no session expireing etc. Now he goes camping till Wednesday.

    Code:
    State after the operation:
    Databse: "Alice Smith, Park Avenue"
    Bob's Browser:  "Alice Smith, Park Avenue"

    In the meantime Charlie opens the record "Alice Smith, Park Avenue" on Tuesday and updates to "Alice Smith, 45 Park Avenue, NY". The record gets update in the database.

    Code:
    State after the operation:
    Database: "Alice Smith, 45 Park Avenue, NY"
    Bob's Browser:  "Alice Smith, Park Avenue"
    Charlie's Browser: "Alice Smith, 45 Park Avenue, NY"
    Now Bob returns on Thursday from camping and finds his browser open presenting the record "Alice Smith, Park Avenue" as it was loaded on Monday. He recognizes that Alice's name is not complete and updates the record to "Alice Nicole Smith, Park Avenue". Note that Charlie's update is being overwritten by Bob's submission of the old/expired field data for the street/state.

    Now the state is:

    Code:
    State after the operation:
    Databse: "Alice Nicole Smith, Park Avenue"
    Bob's Browser:  "Alice Nicole Smith, Park Avenue"
    Charlie's Browser: "Alice Smith, 45 Park Avenue, NY"
    Now the question is: How can you prevent this concurrent (dirty?) update. You'd need some kind of locking mechanism, which tells the service methods (and further the frontend) that the record is currently locked by another user and can't be updated. Also you would need the ability to release locks and so on. I don't have a clue which concepts in spring provide that kind of transactionality through to the web frontend. Please advice.

    Thanks,
    Tobi
    Last edited by byte23; Dec 19th, 2011 at 05:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •