[jboss-user] [Jboss Seam] Transactions

Bram Biesbrouck b at beligum.org
Thu Dec 28 11:59:57 EST 2006


Hi all,

Hi all, I'm struggling with transaction-rollback in Seam for nearly two days 
straight now, tried everything, but it just don't seem to work. I found a 
very nice overview of the possibilities, here: 
http://svn.nuxeo.org/nuxeo/ECMPlatform/NXCore/trunk/doc/Transactions.txt

I tried the different steps, but none work/worked for me.
Please help me out, info follows:

#############My Seam action bean##############""
@Stateful
@Scope(CONVERSATION)
@Name("register")
public class RegisterAction implements IRegister
{
    @In(create=true) @Out
    private Person currentUser;
    @In(create=true) @Out
    private LoginEntity loginEntity;
    
    @In
    private EntityManager em;
    
    //-----CONSTRUCTORS-----
    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.

The two entity beans are two regular, session-scoped beans with nothing 
specific in them (I think).

Please help me out.
If you need more info (web.xml, persistence.xml, ...) just ask.

Bram



More information about the jboss-user mailing list