String userName,userID,classID;
try {
Context ctx = new InitialContext();
UserHome userHome = (UserHome) ctx.lookup("java:/comp/env/User");
User user = userHome.findByPrimary(Integer.valueOf(userID);
userHome.remove(userName);
ClassanduserHome cauHome = (ClassanduserHome) ctx.lookup(
"java:/comp/env/Classanduser");
cauHome.create(Integer.valueOf(userID), Integer.valueOf(classID));
}
catch (Exception e) {
sessionContext.setRollbackOnly();
System.out.println(e.getMessage());
}
when cauHome.create() throw a Exception
userHome.remove() do not rollback
but when i replace userHome.remove() with user.setName("dfd")
when cauHome.create() throw a Exception
user.setName("dfd") rollback success
who can tell me why?
-
ejbRemove() can't be rollback? (4 messages)
- Posted by: getdown milan
- Posted on: June 26 2003 00:54 EDT
Threaded Messages (4)
- ejbRemove() can't be rollback? by Mitchell Ratisher on June 26 2003 02:29 EDT
- re by getdown milan on June 26 2003 04:51 EDT
-
re by Badrish Agarwal on June 26 2003 05:18 EDT
- re by getdown milan on June 27 2003 02:14 EDT
-
re by Badrish Agarwal on June 26 2003 05:18 EDT
- re by getdown milan on June 26 2003 04:51 EDT
-
ejbRemove() can't be rollback?[ Go to top ]
- Posted by: Mitchell Ratisher
- Posted on: June 26 2003 02:29 EDT
- in response to getdown milan
If the remove() method doesn't rollback, I'd say its not in the same transaction. One way that could happen is if ejbRemove() and setName() don't have the same transactional attributes declared. If that doesn't do it, I'm out of ideas :-) -
re[ Go to top ]
- Posted by: getdown milan
- Posted on: June 26 2003 04:51 EDT
- in response to Mitchell Ratisher
Mitchell Ratisher :
can you tell me how to make sure that remove() method and setName() in the
same transaction?
thanks -
re[ Go to top ]
- Posted by: Badrish Agarwal
- Posted on: June 26 2003 05:18 EDT
- in response to getdown milan
Just use the Required transaction attributes for both the EJBs. -
re[ Go to top ]
- Posted by: getdown milan
- Posted on: June 27 2003 02:14 EDT
- in response to Badrish Agarwal
i try that but it doesn't work yet