jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vibhu Sharma <vi...@projectoffguard.com>
Subject Re: User Managed Transactions...
Date Thu, 08 Oct 2009 10:24:56 GMT
I have managed to Run MySQL and Jackrabbit(with Derby Persistence Manager)
wiht JOTM.
Following is the code snippet. This code makes the transactions atomic
across MySQL and Jackrabbit.

/******* code starts ******/
Context ctx = new InitialContext();

// JDBC stuff
DataSource ds =

UserTransaction ut =

System.out.println("<<< beginning the transaction >>>");

// get DB Connection
 java.sql.Connection conn = ds.getConnection();

//getting repository instance
 Repository repository =
 Session session = repository.login(new

 // extract TransactionManager from DatasourceFactory.jotm
 TransactionManager tmanager =

 // extract the current Transaction from TransactionManager
 Transaction trans = tmanager.getTransaction();

 // attach the XAResource from Session to Transaction

 // Perform changes to repository
 Node node = session.getRootNode();

 // ---------- call save() on Node ---> this is very Important
 // without this the changes don't persist even on transaction.commit()

// JDBC statements
// ...
// ...

// Rollback/commit on UserTransaction Object now makes changes in Both DB
and repository
// ut.rollback() or ut.commit()

// cleanup

The complete code for the JOTM tutorial with the Jackrabbit integration is
at :

This may not be completely correct, as I am also new to JTA, but the
transactions done using this method are atomic.
Still searching for the standard solution

Thanks and hope this takes us a little fwd

On Mon, Aug 24, 2009 at 7:20 PM, Gadbury <gadbury@googlemail.com> wrote:

> Hi all,
> Sorry to come back to haunt you all but I am once again confusing myself
> with Transactions.
> There seem to be so many different variations / terms for transactions!
> A local transaction
> A distributed transaction
> A global transaction
> A user transaction
> A container-managed transaction ...?
> I'm guessing some of these are synonyms, and that they're not all
> different!
> Currently, we are looking into the use of the spring-modules-jcr module for
> use with transactions.  I understand that distributed transactions use JTA
> and XA Resource (which I have got running without spring-modules-jcr,
> thanks
> to the help from you all here), but I am not clear what a local transaction
> manager is within spring-modules-jcr.  What is a local transaction?  I am
> trying to work out whether I need to use the local transaction manager or
> the distributed transaction manager in Jackrabbit.  Our concern is that XA
> Transactions are only supported by MySQL for the INNO_DB engine, and we may
> later have a requirement to use Jackrabbit with a clustered database.
> Thanks for reading and any aadvice would be greatly appreciated.
> --
> View this message in context:
> http://www.nabble.com/User-Managed-Transactions...-tp24687924p25116400.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message