List of usage examples for javax.transaction.xa XAResource XA_OK
int XA_OK
To view the source code for javax.transaction.xa XAResource XA_OK.
Click Source Link
From source file:org.nuxeo.ecm.core.storage.sql.TestSQLBackend.java
@Test public void testSaveOnCommit() throws Exception { if (!DatabaseHelper.DATABASE.supportsXA()) { return;//from w w w . j a va2 s . c om } Session session = repository.getConnection(); // init session.save(); XAResource xaresource = ((SessionImpl) session).getXAResource(); // first transaction Xid xid = new XidImpl("11111111111111111111111111111111"); xaresource.start(xid, XAResource.TMNOFLAGS); Node root = session.getRootNode(); assertNotNull(root); session.addChildNode(root, "foo", null, "TestDoc", false); // let end do an implicit save xaresource.end(xid, XAResource.TMSUCCESS); xaresource.prepare(xid); xaresource.commit(xid, false); // should have saved, clearing caches should be harmless ((SessionImpl) session).clearCaches(); // second transaction xid = new XidImpl("22222222222222222222222222222222"); xaresource.start(xid, XAResource.TMNOFLAGS); Node foo = session.getNodeByPath("/foo", null); assertNotNull(foo); xaresource.end(xid, XAResource.TMSUCCESS); int outcome = xaresource.prepare(xid); if (outcome == XAResource.XA_OK) { // Derby doesn't allow rollback if prepare returned XA_RDONLY xaresource.rollback(xid); } }