Discussions

General J2EE: Can J2EE Transaction services do this?

  1. Can J2EE Transaction services do this? (4 messages)

    Hi,
       I have a certain requirement for our transaction framework and I wish to know if there are available tools/strategies to achieve this.
       We are planning to write our own transaction infrastructureto handle update transactions, which checks if the DB rows are not modified since this user performed a "select", and locks all the relevant rows and performs the update. Since the J2EE transaction framework do not seem to support this, we are forced to write our own.
      I believe this is a very common requirement for most web applications and am curious how it is handled.
      
    Any comments would be appreciated,
  2. As far as I understood you - you need a transaction isolation level that will allow you to update data, but to ensure that no other updates will take place during your update? I think it's not a good idea to lock tables, I think you must just rely on the last update and if you want to show to your users only updated data (and not intermediate ones) - just use TX_READ_COMMITED transaction isolation level...

    Alex.
  3. I think you want some type of optimistic locking control along the lines of a version number or timestamp. TopLink provides this for you, I'm sure the other OR tools out there will also support this. Websphere EJB has something like this, you may want to check it out more.

    --
    Tinou Bao
    www.tinou.com
  4. Hi,
    U can set up a timestamp column in ur DB and in ur Entity Bean check to make sure the Time stamp on the DB row matches the TimeStamp on ur data and set the CTX.setRollBackOnly on ur entityBean if there is a difference. This will take care of your problem I guess.

     
  5. Look in the EJB design discussions
    The problem of optimistic locking and long transactions is covered several times.
    Moore