0 Replies Latest reply on Jul 12, 2003 4:51 AM by ittay

    finder returns wrong results

    ittay Newbie

      I have an entity bean EntBean. It has an Integer property named 'foo' and a finder findByFooNotNull().

      I have a stateless session bean SessBean with a method m() which calls on EntBean's methods:
      public void m() {
      Collection c = entLocalHome.findByFooNotNull();
      EntLocal ent = (EntLocal)c.iterator().next();
      ent.setFoo(new Integer(1));
      }

      I have two threads calling m() (through SessLocal).

      The first gets the collection, and changes the first object to have foo==1. If I inspect it (in debugger or print-debug) then ent.getFoo() returns 1.

      The second gets the *same* collection, and the first element is the same bean, but calling getFoo() on it returns null.

      I've also inspected the db between calls and the columns do change as needed.

      My guess is that the second thread enters m() before the first one completes its call chain up to the calling client. So JBoss doesn't update its internal data when the second thread enters the method.

      I know of the problem where finder methods work on the DB, so they can return the same objects because the DB hasn't been updated yet, but here it seems the object's data is reset in the second thread.


      Thanks for your help,
      Ittay