Package org.springframework.transaction

Examples of org.springframework.transaction.TransactionDefinition


    private boolean readOnly;

    public TransactionStatus getTransaction(TransactionDefinition definition)
            throws TransactionException {
        if (readOnly) {
            TransactionDefinition readOnlyTransactionDefinition = new ReadOnlyTransactionDefinition(
                    definition);

            return platformTransactionManager
                    .getTransaction(readOnlyTransactionDefinition);
        } else {
View Full Code Here


            return;
        }

        TransactionAttribute transactionAttribute =
                this.attributeSource.getTransactionAttribute(testMethod, testContext.getTestClass());
        TransactionDefinition transactionDefinition = null;
        if (transactionAttribute != null) {
            transactionDefinition = new DelegatingTransactionAttribute(transactionAttribute) {
                public String getName() {
                    return testMethod.getName();
                }
View Full Code Here

    }
  }

  @BeforeMethod
  protected void checkTransaction(Method testMethod) throws Throwable {   
    TransactionDefinition explicitTransactionDefinition =
        this.transactionAttributeSource.getTransactionAttribute(testMethod, getClass());
    if (explicitTransactionDefinition != null) {
      logger.info("Custom transaction definition [" + explicitTransactionDefinition + " for test method " + testMethod.getName());
      setTransactionDefinition(explicitTransactionDefinition);
    }
View Full Code Here

    }
  }

  @Test
  public void testDefaultBeginTransaction() throws Exception {
    TransactionDefinition definition = new DefaultTransactionDefinition();
    EntityManager entityManager = mock(EntityManager.class);
    EntityTransaction entityTx = mock(EntityTransaction.class);

    given(entityManager.getTransaction()).willReturn(entityTx);
View Full Code Here

  }

  @Test
  public void testMatchAlwaysTransactionAttributeSourceWithNulls() throws Exception {
    MatchAlwaysTransactionAttributeSource tas = new MatchAlwaysTransactionAttributeSource();
    TransactionDefinition definition = tas.getTransactionAttribute(null, null);
    assertEquals(TransactionDefinition.PROPAGATION_REQUIRED, definition.getPropagationBehavior());
    assertEquals(TransactionDefinition.ISOLATION_DEFAULT, definition.getIsolationLevel());
    assertEquals(TransactionDefinition.TIMEOUT_DEFAULT, definition.getTimeout());
    assertFalse(definition.isReadOnly());
  }
View Full Code Here

      return;
    }

    final Method testMethod = getTestMethod();

    TransactionDefinition explicitTransactionDefinition = this.transactionAttributeSource.getTransactionAttribute(
      testMethod, getClass());
    if (explicitTransactionDefinition != null) {
      this.logger.info("Custom transaction definition [" + explicitTransactionDefinition + "] for test method ["
          + getName() + "].");
      setTransactionDefinition(explicitTransactionDefinition);
View Full Code Here

        when(underlyingTransactionStatus.isNewTransaction()).thenReturn(true);
    }

    @Test
    public void testManageTransaction_CustomTransactionStatus() {
        final TransactionDefinition transactionDefinition = mock(TransactionDefinition.class);
        testSubject.setTransactionDefinition(transactionDefinition);
        TransactionStatus transaction = testSubject.startTransaction();
        testSubject.commitTransaction(transaction);

        verify(transactionManager).getTransaction(transactionDefinition);
View Full Code Here

      return;
    }

    TransactionAttribute transactionAttribute =
        this.attributeSource.getTransactionAttribute(testMethod, testContext.getTestClass());
    TransactionDefinition transactionDefinition = null;
    if (transactionAttribute != null) {
      transactionDefinition = new DelegatingTransactionAttribute(transactionAttribute) {
        public String getName() {
          return testMethod.getName();
        }
View Full Code Here

   * @param transactionManager
   */
  private void setTransaction(PlatformTransactionManager transactionManager) {
    this.transactionManager = transactionManager;
    if (this.transactionManager != null) {
      TransactionDefinition transactionDefinition = new DefaultTransactionDefinition(
          TransactionDefinition.PROPAGATION_REQUIRED);
      this.transactionStatus = transactionManager.getTransaction(transactionDefinition);
    }
  }
View Full Code Here

    setupContext();
    DoSQL me = new DoSQL();
    String sql = join(args, " ");
   
    HibernateTransactionManager htm = ContextManager.getTransactionManager();
    TransactionDefinition transDef = new DefaultTransactionDefinition();
    TransactionStatus transStatus = htm.getTransaction(transDef);
    SessionFactory sf = ContextManager.getSessionFactory();
    Session sess = sf.getCurrentSession();
    SQLQuery q = sess.createSQLQuery(sql);
    q.executeUpdate();
View Full Code Here

TOP

Related Classes of org.springframework.transaction.TransactionDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.