[jbossseam-issues] Transactions

Bram Biesbrouck b at beligum.org
Thu Dec 28 11:52:51 EST 2006


I've been searching for solutions 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.

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

Bram


On Thursday 28 December 2006 14:06, Bram Biesbrouck wrote:
> Hi all,
>
> Could someone point me the different options I have to use transactions
> using JBoss Seam?
> I've read about @Rollback, @Transactional, @ApplicationException,
> setRollbackOnly() and I'm a little confused.
>
> Can I get a clear reply from someone with a little more expertise?
>
> thx,
>
> Bram
> _______________________________________________
> jbossseam-issues mailing list
> jbossseam-issues at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbossseam-issues



More information about the seam-issues mailing list