[jboss-user] [JBoss Seam] - Transaction rollback doesn't work
beligum
do-not-reply at jboss.com
Fri Dec 29 04:38:47 EST 2006
Hello,
I've got major problems with my transaction-rollback implementation, and I'm reading manuals for over two days now (I really like
http://svn.nuxeo.org/nuxeo/ECMPlatform/NXCore/trunk/doc/Transactions.txt ), and I'm getting frustrated.
The problem is fairly easy; I'm implemention a user-registration action bean, RegisterAction, that implements IRegister, marked @Local. Here it is:
| @Stateful
| @Scope(CONVERSATION)
| @Name("register")
| public class RegisterAction implements IRegister
| {
| @In(create=true) @Out
| private Person currentUser;
| @In(create=true) @Out
| private LoginEntity loginEntity;
|
| @PersistenceContext
| private EntityManager em;
|
| public RegisterAction()
| {
| }
|
| @Rollback(ifOutcome= {"failure"})
| @End
| public String register()
| {
| try {
| this.em.persist(this.currentUser);
| this.em.persist(this.loginEntity); //this one throws an Exception
| }
| catch (Exception e) {
| return "failure";
| }
|
| return "success";
| }
| @Remove @Destroy
| public void destroy()
| {
| }
| }
|
As you can see, I try to persist two objects, the first one succeeds (and is
persisted in the DB), the second one doesn't and throws an exception, causing
the method to return "failure" and should rollback, but it doesn't: the first
objects gets persisted in the DB, but it should't, because of the rollback.
Please tell me what I'm doing wrong or what misconfiguration I'm overseeing.
regards,
Bram
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996800#3996800
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996800
More information about the jboss-user
mailing list