Hi Paul,
you're right, session.save() will either save all or nothing, so you
don't really need transactions here. But just out of curiosity - and
because and I don't think anything is wrong with your sample code -
can you tell me how you set up your repository in the JNDI context?
Kind regards
Dominique
On 2/28/07, Paul Eggerling-Boeck <[EMAIL PROTECTED]> wrote:
I read the Jackrabbit FAQ about transactions and have implemented
something like the following:
InitialContext context = new InitialContext();
Context environment = (Context) context.lookup("java:comp/env");
Repository repository = (Repository) environment.lookup("jcr/repository");
XASession session = (XASession)repository.login(new
SimpleCredentials("username", "password".toCharArray()), null);
XAResource xares = session.getXAResource();
// XID stuff from FAQ is next
xares.start(xid, XAResource.TMNOFLAGS);
// Create some nodes and properties
session.save();
xares.end(xid, XAResource.TMSUCCESS);
xares.rollback(xid);
Note that I'm testing a rollback here so there's no xares.prepare() or
xares.commit();
My problem is that the changes get persisted and not rolled back. I'm
not using a UserTransaction or any transaction manager, just going at
the XAResource directly. I read in the archives that the
session.save() method is all-or-nothing in and of itself so do I
really even need to do XA transactions if I just want to make sure all
my changes to the session are persisted as a unit?
Am I doing something wrong? Anybody else run into this?
BTW, I'm using
org.apache.jackrabbit.core.fs.local.LocalFileSystem and
org.apache.jackrabbit.core.state.db.DerbyPersistenceManager
Thanks,
Paul