0 Replies Latest reply on Sep 23, 2005 7:17 PM by Jacky Chan

    How to prevent Dirty Read while updating a counter

    Jacky Chan Newbie

      Hi, I'm using Jboss 3.2.6. We use:
      in our system for performance issues. However, it creates persistency problems.

      There is a bean with a function like this:
      1) check if entry "abc" exist, save result in a flag
      2) add "abc" to the table
      3) if flag is true, add one to the counter. otherwise, don't change the counter

      This works fine most of the time. However, if two events try to add the same entry "abc" at the same time, they both get the "true" flag after step one. As a result, the counter was incremented twice instead of once. Is there any way I can tell jboss that, step 1 and 3 must be ran exclusively, or somehow, block other transaction that's trying to read the table to prevent the dirty read? or there is a setting I can use for this particular bean to prevent the dirty read?

      Any help or suggestion would be highly appreciated. Thanks.