0 Replies Latest reply on Jun 25, 2003 12:07 PM by cocobase

    a transaction'sproblem about CMP

    cocobase Newbie

      /****** /
      UserTranaction utx = null;
      try {
      Context ctx = new InitialContext();
      utx = (UserTransaction) ctx.lookup("java:/comp/UserTransaction");
      utx.begin();
      UserHome userHome = (UserHome) ctx.lookup("User");
      User user = userHome.findByPrimaryKey(Integer.valueOf("9"));
      user.setName("user1");
      ClassanduserHome home = (ClassanduserHome) ctx.lookup("Classanduser");
      Classanduser classanduser = home.create(Integer.valueOf("2"), Integer.valueOf("2"));
      utx.commit();
      System.out.println(classanduser.getClassID());
      }
      catch (Exception e) {
      System.out.println(e.getMessage());
      }
      /****** /
      when Classanduser classanduser = home.create(Integer.valueOf("2"), Integer.valueOf("2")); throws Exception
      user.setName("user1") can rollback

      but when replace user.setName("user1") with
      user.remove() or userHome.create("user2")
      it can't rollback

      who can help me please!