0 Replies Latest reply on Jul 27, 2005 8:51 AM by gabi munteanu

    synchrinizying a slsb method

    gabi munteanu Newbie

      Hello,

      i have a method in a session bean that handles the creation of a user.
      before calling the method createUser on an EJB, it checks some finder methods to see if the username,email and phone number already exists in the database.

      so i have something like this:
      findByUsername
      if not found
      findByEmail
      if not
      findByPhone
      if not
      createUser

      Well, i want this block synchronized, because this stateless session bean is called by many servlets concurrently, and if someone with username jgabios reaches the findByPhone method, and another one with the same username reaches findByUsername, since the first jgabios is not created then it passes the test, but it should not. Then the first jgabios is created and then the second one comes along and it throws an exception.

      How can i synchronize all this.
      all the block above is in a business method of the stateless session bean called slsbCreateUser(String username,....).

      Thank you in advance