0 Replies Latest reply on Mar 24, 2003 2:12 AM by Eric Chow

    Transaction rollback problem???

    Eric Chow Apprentice

      I created two EntityBean in a method of a SessionBean and set another existed EntityBean in the fresh created EntityBean.

      It did not rollback when some exception raised.

      Please see my methods in SessionBean.

      public void addUser(Long id, String username, String password, String sex, Date birth) throws EJBException, CreateException {
      try {
      GenericUserHome userHome = getGenericUserHome();
      GenericUser user = userHome.create(username, password);

      GenericUserInfoHome infoHome = getGenericUserInfoHome();

      GenericUserInfo info = infoHome.create(id, sex, birth);


      Set roles = user.getGenericUserRoles();

      GenericUserRole role = getUserRole("user");

      if (!containsRole(user, role)) {


      } catch(Exception e) {

      I tested in the following cases:

      1. USER created successfully, but INFO failed to created, --> ROLLBACK success(USER will be removed by the container)

      2. USER and INFO created successfully, but failed to set the ROLE to USER ---> DID NOT ROLLBACK(USER and INFO still store in DB).

      Please tell me why and how to solve this ?

      I am using JBoss-3.0.6 + MySQL in Win98 with JDK1.4.1.

      Best regards,