8.1.2 User Managed Transactions: Sample Code

// Get user transaction (for example, through JNDI)

UserTransaction utx = ...


// Get a node

Node n = ...


// Start a user transaction

utx.begin();


// Do some work

n.setProperty("myapp:title", "A Tale of Two Cities")

n.save();

// Do some more work

n.setProperty("myapp:author", "Charles Dickens")

n.save();


// Commit the user transaction

utx.commit();