@Test public void testPasswordConverter() { logger.info("starting persistence converter test"); Citizen citizen = new Citizen(); citizen.setPassword("prova"); try { userTransaction.begin(); entityManager.persist(citizen); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } Citizen citizenFromDB = (Citizen) entityManager.createQuery("from citizen").getSingleResult(); assertEquals("the password is always converted by the converter", "prova", citizenFromDB.getPassword()); assertEquals("this is the password we have in the database", "cHJvdmE=", NEVER_DO_IT); }
/** * Tests annotation literals in a jar archive */ @Test @SuppressWarnings("unchecked") public void testSingleTable() { logger.info("starting single table inheritance test"); Pet pet = new Pet("jackrussell", "dog"); Dog dog = new Dog("mastino", "dog"); try { userTransaction.begin(); entityManager.persist(pet); entityManager.persist(dog); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } List<Pet> petsFromDB = entityManager.createNativeQuery("select * from pet").getResultList(); assertEquals("only the pet table exists", 2, petsFromDB.size()); }
/** * Tests annotation literals in a jar archive */ @Test @SuppressWarnings("unchecked") public void testTablePerClass() { logger.info("starting table per class inheritance test"); Vehicle vehicle = new Vehicle("peugeot", "car"); Car car = new Car("fiat", "car"); try { userTransaction.begin(); entityManager.persist(vehicle); entityManager.persist(car); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } List<Vehicle> vehiclesFromDB = entityManager.createNativeQuery("select * from vehicle").getResultList(); assertEquals("the vehicle table exists", 1, vehiclesFromDB.size()); List<Car> carsFromDB = entityManager.createNativeQuery("select * from car").getResultList(); assertEquals("the car table exists", 1, carsFromDB.size()); }
/** * Tests annotation literals in a jar archive */ @Test @SuppressWarnings("unchecked") public void testJoin() { logger.info("starting joined inheritance event test"); Watch watch = new Watch(); TopicWatch topicWatch = new TopicWatch(); try { userTransaction.begin(); entityManager.persist(watch); entityManager.persist(topicWatch); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } List<Watch> watchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_WATCH").getResultList(); assertEquals("the watch table exists", 2, watchesFromDB.size()); List<TopicWatch> topicWatchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_TOPICSWATCH") .getResultList(); assertEquals("the topic watch table exists", 1, topicWatchesFromDB.size()); }
@Test public void testSearch() { Forum forum = entityManager.find(Forum.class, 0); Poster poster = new Poster("root"); Topic topic = new Topic(forum, TOPIC_TEXT); topic.setPoster(poster); Post post = new Post(topic, POST_TEXT); post.setCreateDate(new Date()); post.setPoster(poster); try { userTransaction.begin(); entityManager.persist(poster); entityManager.persist(topic); entityManager.persist(post); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { e.printStackTrace(); } List<Topic> topics = findTopics(); List<Post> posts = findPosts(); assertEquals("find topics", 1, topics.size()); assertEquals("find posts", 1, posts.size()); }
@Test public void testDeleteManyToMany() { logger.info("starting merge many to many cascade test"); testPersistManyToMany(); try { userTransaction.begin(); Author davide_scala = (Author) entityManager.createQuery("from Author where fullName = :fullName") .setParameter("fullName", "Davide Scala").getSingleResult(); davide_scala.remove(); entityManager.remove(davide_scala); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } @SuppressWarnings("unchecked") List<Book> booksFromDb = entityManager.createNativeQuery("select * from Book").getResultList(); assertEquals("the book table exists", 2, booksFromDb.size()); @SuppressWarnings("unchecked") List<Author> authorsFromDb = entityManager.createNativeQuery("select * from Author").getResultList(); assertEquals("the author table exists", 2, authorsFromDb.size()); @SuppressWarnings("unchecked") List<Author> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_Author").getResultList(); assertEquals("the author table exists", 4, bookAuthorsFromDb.size()); }
@Test public void testDeleteBooksAllManyToMany() { logger.info("starting merge many to many cascade test"); testPersistManyToMany(); try { userTransaction.begin(); PMAuthor davide_scala = (PMAuthor) entityManager.createQuery("from PMAuthor where fullName = :fullName") .setParameter("fullName", "Davide Scala").getSingleResult(); entityManager.remove(davide_scala); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } @SuppressWarnings("unchecked") List<PMBook> booksFromDb = entityManager.createNativeQuery("select * from PMBook").getResultList(); assertEquals("the pm book table exists", 1, booksFromDb.size()); @SuppressWarnings("unchecked") List<PMAuthor> authorsFromDb = entityManager.createNativeQuery("select * from PMAuthor").getResultList(); assertEquals("the pm author table exists", 2, authorsFromDb.size()); @SuppressWarnings("unchecked") List<PMAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_PM_Author") .getResultList(); assertEquals("the pm book author table exists", 2, bookAuthorsFromDb.size()); }
@Test public void testDeleteBooksJoinTableAllManyToMany() { logger.info("starting merge many to many cascade test"); testPersistManyToMany(); try { userTransaction.begin(); AllAuthor davide_scala = (AllAuthor) entityManager.createQuery("from AllAuthor where fullName = :fullName") .setParameter("fullName", "Davide Scala").getSingleResult(); entityManager.remove(davide_scala); userTransaction.commit(); } catch (NotSupportedException | SystemException | IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | RollbackException e) { fail(); } @SuppressWarnings("unchecked") List<AllBook> booksFromDb = entityManager.createNativeQuery("select * from AllBook").getResultList(); assertEquals("the all book table doesn't exist", 0, booksFromDb.size()); @SuppressWarnings("unchecked") List<AllAuthor> authorsFromDb = entityManager.createNativeQuery("select * from AllAuthor").getResultList(); assertEquals("the all author table doesn't exist", 0, authorsFromDb.size()); @SuppressWarnings("unchecked") List<AllAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_All_Author") .getResultList(); assertEquals("the all book author table exists", 0, bookAuthorsFromDb.size()); }
/** * Tests the fire of the event inside a transaction */ @Test public void testSimpleTransaction() { try { userTransaction.begin(); Bill bill = fire(); assertEquals( "The id generation passes through the always and it is incremented only by inprogess always observer method", 1, bill.getId()); userTransaction.commit(); assertEquals( "The id generation passes through the always and it is incremented only by transactional observer methods", 4, bill.getId()); } catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) { fail("no fail for the transaction"); } }
public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException { try { if (isRollBackOnly) { throw new RollbackException("Commit failed: Transaction marked for rollback"); } } finally { transaction.set(null); } }
private void createUsers() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException { txn = transactionService.getUserTransaction(); txn.begin(); for (UserInfo user : userInfos) { String username = user.getUserName(); NodeRef nodeRef = personService.getPersonOrNull(username); boolean create = nodeRef == null; if (create) { PropertyMap testUser = new PropertyMap(); testUser.put(ContentModel.PROP_USERNAME, username); testUser.put(ContentModel.PROP_FIRSTNAME, user.getFirstName()); testUser.put(ContentModel.PROP_LASTNAME, user.getLastName()); testUser.put(ContentModel.PROP_EMAIL, user.getUserName() + "@acme.test"); testUser.put(ContentModel.PROP_PASSWORD, "password"); nodeRef = personService.createPerson(testUser); } userNodeRefs.add(nodeRef); // System.out.println((create ? "create" : "existing")+" user " + username + " nodeRef=" + nodeRef); } txn.commit(); }
@Test @DisplayName( "Multiple close test" ) public void multipleCloseTest() throws SQLException { TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager(); TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple(); AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier() .connectionPoolConfiguration( cp -> cp .transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) ) ); try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) { // there is a call to connection#close in the try-with-resources block and another on the callback from the transaction#commit() try ( Connection connection = dataSource.getConnection() ) { logger.info( format( "Got connection {0}", connection ) ); try { txManager.begin(); txManager.commit(); } catch ( NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e ) { fail( "Exception: " + e.getMessage() ); } } } }
/** * Configuración inicial de la prueba. * * @generated */ @Before public void configTest() { try { utx.begin(); clearData(); insertData(); utx.commit(); } catch (IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | NotSupportedException | RollbackException | SystemException e) { e.printStackTrace(); try { utx.rollback(); } catch (IllegalStateException | SecurityException | SystemException e1) { e1.printStackTrace(); } } }
/** * Configuración inicial de la prueba. * * @generated */ @Before public void configTest() { try { utx.begin(); clearData(); insertData(); utx.commit(); } catch (IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | NotSupportedException | RollbackException | SystemException e) { e.printStackTrace(); try { utx.rollback(); } catch (IllegalStateException | SecurityException | SystemException e1) { e1.printStackTrace(); } } }
public UserTransaction getUserTransaction() { return new UserTransaction() { public void begin() throws NotSupportedException, SystemException { } public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { } public int getStatus() throws SystemException { return TransactionUtil.STATUS_NO_TRANSACTION; } public void rollback() throws IllegalStateException, SecurityException, SystemException { } public void setRollbackOnly() throws IllegalStateException, SystemException { } public void setTransactionTimeout(int i) throws SystemException { } }; }
protected void invokeTransactionCommitIfNotLocalTransaction(CompensableTransaction compensable) throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction transaction = compensable.getTransaction(); org.bytesoft.transaction.TransactionContext transactionContext = transaction.getTransactionContext(); RemoteCoordinator transactionCoordinator = this.beanFactory.getTransactionCoordinator(); TransactionXid transactionXid = transactionContext.getXid(); try { transactionCoordinator.end(transactionContext, XAResource.TMSUCCESS); TransactionContext compensableContext = compensable.getTransactionContext(); logger.error("[{}] jta-transaction in try-phase cannot be xa transaction.", ByteUtils.byteArrayToString(compensableContext.getXid().getGlobalTransactionId())); transactionCoordinator.rollback(transactionXid); throw new HeuristicRollbackException(); } catch (XAException xaEx) { transactionCoordinator.forgetQuietly(transactionXid); SystemException sysEx = new SystemException(); sysEx.initCause(xaEx); throw sysEx; } }
public void compensableCommit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { CompensableManager tompensableManager = this.beanFactory.getCompensableManager(); CompensableTransaction compensable = (CompensableTransaction) tompensableManager.getCompensableTransactionQuietly(); if (compensable == null) { throw new IllegalStateException(); } TransactionContext transactionContext = compensable.getTransactionContext(); if (transactionContext.isCoordinator() == false) { throw new IllegalStateException(); } this.invokeCompensableCommit(compensable); }
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { if (this.transactionStatus == Status.STATUS_ACTIVE) { this.fireCommit(); } else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { this.fireRollback(); throw new HeuristicRollbackException(); } else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ { throw new RollbackException(); } else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ { logger.debug("Current transaction has already been committed."); } else { throw new IllegalStateException(); } }
protected void truncateTables(String... tables) { try { utx.begin(); for (String table : tables) { StringBuilder deleteQueryBuilder = new StringBuilder("delete from "); deleteQueryBuilder.append(table); getEm().createQuery(deleteQueryBuilder.toString()).executeUpdate(); } utx.commit(); } catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) { try { utx.rollback(); } catch (IllegalStateException | SecurityException | SystemException e1) { } } }
@Override public void commit() { if (initiatedTransaction) { try { transactionListener.beforeCommit(entities.types()); getUserTransaction().commit(); transactionListener.afterCommit(entities.types()); } catch (RollbackException | SystemException | HeuristicMixedException | HeuristicRollbackException e) { throw new TransactionException(e); } } try { entities.clear(); } finally { close(); } }
public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException { TransactionImpl global = this.getCurrentTransaction(); TransactionContext transactionContext = global.getTransactionContext(); boolean compensable = transactionContext.isCompensable(); boolean coordinator = transactionContext.isCoordinator(); if (compensable == false) { this.commitRegularTransaction(global); } else if (coordinator) { if (global.isTransactionCompleting()) { global.commitCompleteTransaction(); } else { this.commitGlobalTransaction(global); } } else if (global.isTransactionCompleting()) { global.commitCompleteTransaction(); } else { global.commitTryingTransaction(); } }
/** * This test will publish set of messages through XA transaction and then rollback, then publish another set of * messages. All this time a consumer will be running on the particular Queue, and total of the consumed messages * should be equal to the total number of committed messages. * * @throws JMSConnectorException Error when sending messages through JMS transport connector. * @throws InterruptedException Interruption when thread sleep. * @throws JMSException Error when running the test message consumer. * @throws SystemException XA Transaction exceptions. * @throws NotSupportedException Transaction exceptions. * @throws RollbackException Transaction exceptions. * @throws HeuristicRollbackException Transaction exceptions. * @throws HeuristicMixedException Transaction exceptions. * @throws NoSuchFieldException Error when accessing the private field. * @throws IllegalAccessException Error when accessing the private field. */ @Test(groups = "jmsSending", description = "XA transacted queue sending tested case") public void queueSendingTestCase() throws JMSConnectorException, InterruptedException, JMSException, SystemException, NotSupportedException, RollbackException, HeuristicRollbackException, HeuristicMixedException, NoSuchFieldException, IllegalAccessException { // Run message consumer and publish messages performPublishAndConsume(jmsClientConnectorQueue, xaQueueName, false); JMSTestUtils.closeResources((JMSClientConnectorImpl) jmsClientConnectorQueue); Assert.assertEquals(receivedMsgCount, 5, "XA transacted queue sender expected message count " + 5 + " , received message count " + receivedMsgCount); }
/** * This test will publish set of messages through XA transaction and then rollback, then publish another set of * messages. All this time a consumer will be running on the particular Topic, and total of the consumed messages * should be equal to the total number of committed messages. * * @throws JMSConnectorException Error when sending messages through JMS transport connector. * @throws InterruptedException Interruption when thread sleep. * @throws JMSException Error when running the test message consumer. * @throws SystemException XA Transaction exceptions. * @throws NotSupportedException Transaction exceptions. * @throws RollbackException Transaction exceptions. * @throws HeuristicRollbackException Transaction exceptions. * @throws HeuristicMixedException Transaction exceptions. * @throws NoSuchFieldException Error when accessing the private field. * @throws IllegalAccessException Error when accessing the private field. */ @Test(groups = "jmsSending", description = "XA transacted topic sending tested case") public void topicSendingTestCase() throws JMSConnectorException, InterruptedException, JMSException, SystemException, NotSupportedException, RollbackException, HeuristicRollbackException, HeuristicMixedException, NoSuchFieldException, IllegalAccessException { // Run message consumer and publish messages performPublishAndConsume(jmsClientConnectorTopic, xaTopicName, true); JMSTestUtils.closeResources((JMSClientConnectorImpl) jmsClientConnectorTopic); Assert.assertEquals(receivedMsgCount, 5, "XA transacted topic sender expected message count " + 5 + " , received message count " + receivedMsgCount); }
/** * Commit. * @throws HandlerException oops */ public void commit() throws HandlerException { if (_isInitiator) { try { _userTx.commit(); } catch (SystemException se) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedSystem(se); } catch (HeuristicRollbackException hre) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedRollback(hre); } catch (HeuristicMixedException hme) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedMixed(hme); } catch (RollbackException re) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailed(re); } } }
public synchronized void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, CommitRequiredException, SystemException { if (this.transactionStatus == Status.STATUS_ACTIVE) { this.fireCommit(); } else if (this.transactionStatus == Status.STATUS_MARKED_ROLLBACK) { this.fireRollback(); throw new HeuristicRollbackException(); } else if (this.transactionStatus == Status.STATUS_ROLLEDBACK) /* should never happen */ { throw new RollbackException(); } else if (this.transactionStatus == Status.STATUS_COMMITTED) /* should never happen */ { logger.debug("Current transaction has already been committed."); } else { throw new IllegalStateException(); } }
public void commit(Xid xid) throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException { try { this.terminator.commit(xid, false); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURCOM: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURRB: throw new HeuristicRollbackException(); default: logger.error("Unknown state in committing transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in committing transaction phase.", rex); throw new SystemException(); } }
public void rollback(Xid xid) throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException { try { this.terminator.rollback(xid); } catch (XAException xaex) { switch (xaex.errorCode) { case XAException.XA_HEURRB: break; case XAException.XA_HEURMIX: throw new HeuristicMixedException(); case XAException.XA_HEURCOM: throw new HeuristicCommitException(); default: logger.error("Unknown state in rollingback transaction phase.", xaex); throw new SystemException(); } } catch (RuntimeException rex) { logger.error("Unknown state in rollingback transaction phase.", rex); throw new SystemException(); } }
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Promotion> resultList = null; try { tx.begin(); resultList = entityManager.createNamedQuery("Promotion.findAll") .getResultList(); for (Promotion promotion : resultList) { promotion.getPersonnes().size(); } tx.commit(); } catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } request.setAttribute("promotions", resultList); request.getRequestDispatcher("WEB-INF/promotions.jsp").forward(request, response); }
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Promotion result = null; String promotionIdString = request.getParameter("promotionId"); Integer promotionId = Integer.valueOf(promotionIdString); try { tx.begin(); result = entityManager.find(Promotion.class, promotionId); result.getPersonnes().size(); tx.commit(); } catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException | HeuristicMixedException | HeuristicRollbackException e) { // TODO Auto-generated catch block e.printStackTrace(); } request.setAttribute("promotion", result); request.getRequestDispatcher("WEB-INF/promotion.jsp").forward(request, response); }
@Override public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, SystemException { if (this.status == Status.STATUS_ROLLEDBACK) { throw new RollbackException("the transaction had been rolled back"); } if (this.rollbackOnly) { this.rollback(); return; } if (this.status != Status.STATUS_ACTIVE) { throw new IllegalStateException("the transaction is not active"); } this.tryEndResource(); boolean preparedSuccess = this.tryPrepared(); if (preparedSuccess) { this.tryCommit(); return; } try { this.tryRollback(); } catch (SystemException e) { throw new HeuristicRollbackException(e.getMessage()); } throw new HeuristicRollbackException("roll back all the transaction"); }
private void tryCommit() throws HeuristicMixedException, SystemException { this.status = Status.STATUS_COMMITTING; ResourceCarry carryTemp = null; Iterator<ResourceCarry> itr = this.resList.iterator(); while (itr.hasNext()) { ResourceCarry carry = itr.next(); this.beforeCompletion(); try { carry.xaRes.commit(carry.xid, false); } catch (XAException e) { LOGGER.error("commit XA error(code=" + e.errorCode + "): ", e); carryTemp = carry; break; } this.afterCompletion(Status.STATUS_COMMITTED); } if (carryTemp == null) { this.status = Status.STATUS_COMMITTED; return; } this.rollbackMixed(carryTemp, itr); }
/** Commit. * * @throws HandlerException oops */ public void commit() throws HandlerException { if (_isInitiator) { try { _userTx.commit(); } catch (SystemException se) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedSystem(se); } catch (HeuristicRollbackException hre) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedRollback(hre); } catch (HeuristicMixedException hme) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailedMixed(hme); } catch (RollbackException re) { throw CommonKnowledgeMessages.MESSAGES.userTransactionCommitFailed(re); } } }
/** * {@inheritDoc} */ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = registry.getTransaction(); if (tx == null) throw new SystemException(); if (tx.getStatus() == Status.STATUS_ROLLEDBACK || tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) throw new RollbackException(); registry.commitTransaction(); }
/** * {@inheritDoc} */ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { if (status == Status.STATUS_UNKNOWN) throw new IllegalStateException("Status unknown"); if (status == Status.STATUS_MARKED_ROLLBACK) throw new IllegalStateException("Status marked rollback"); finish(true); }
/** * {@inheritDoc} */ public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException { Transaction tx = registry.getTransaction(); if (tx == null) throw new SystemException(); if (tx.getStatus() == Status.STATUS_ROLLING_BACK || tx.getStatus() == Status.STATUS_ROLLEDBACK || tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) throw new RollbackException(); registry.commitTransaction(); }
private void rollbackCommit( Thread thread, ReadOnlyTransactionImpl tx ) throws HeuristicMixedException, RollbackException { try { tx.doRollback(); } catch ( XAException e ) { log.log( Level.SEVERE, "Unable to rollback marked transaction. " + "Some resources may be commited others not. " + "Neo4j kernel should be SHUTDOWN for " + "resource maintance and transaction recovery ---->", e ); throw Exceptions.withCause( new HeuristicMixedException( "Unable to rollback " + " ---> error code for rollback: " + e.errorCode ), e ); } tx.doAfterCompletion(); txThreadMap.remove( thread ); tx.setStatus( Status.STATUS_NO_TRANSACTION ); throw new RollbackException( "Failed to commit, transaction rolledback" ); }
private void validateOneToManyRelationship() throws NotSupportedException, SystemException, Exception, HeuristicMixedException, HeuristicRollbackException, RollbackException { try { final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1); // verify one side has a set containing the many bean final Set set = inverseLocal.getManyOwningSide(); Assert.assertEquals(1, set.size()); final ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next(); Assert.assertEquals(compoundPK_20_10, owningLocal.getPrimaryKey()); // verify the many bean has a back reference to the one final OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide(); Assert.assertNotNull(oneInverseSide); Assert.assertEquals(compoundPK_20_10_field1, oneInverseSide.getPrimaryKey()); completeTransaction(); } finally { completeTransaction(); } }