Examples of DefaultTransactionDefinition


Examples of org.springframework.transaction.support.DefaultTransactionDefinition

        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.rollback(status);
       
        // First id
        id1 = emp1.getId();
       
        // Now, make a save with commit and verify that the id is the same as before,
        // because the new transaction must re-assign the id assigned in the previously
        // rolled back transaction:
       
        status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        this.template.save(emp2);
        this.transactionManager.commit(status);
       
        // Second id
        id2 = emp2.getId();
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

        EmployeeImpl emp2 = new EmployeeImpl("a2");
        Long id1 = null;
        Long id2 = null;
       
        // Get the transaction for the first time:
        TransactionStatus status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        // Save
        this.template.save(emp1);
        // Rollback
        this.transactionManager.commit(status);
       
        // First id
        id1 = emp1.getId();
       
        // Now, make a save with commit and verify that the id is equal to the previous id plus one:
       
        status = this.transactionManager.getTransaction(new DefaultTransactionDefinition());
        this.template.save(emp2);
        this.transactionManager.commit(status);
       
        // Second id
        id2 = emp2.getId();
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

   
    public void testConcurrency() throws InterruptedException {
        Runnable r1 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a1");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
                assertNotNull(emp2);
                assertEquals("First: " + emp1.getMatriculationCode() + " - Second: "+ emp2.getMatriculationCode(), emp1, emp2);
            }
        };
       
        Runnable r2 = new Runnable() {
            public void run() {
                EmployeeImpl emp1 = new EmployeeImpl("a2");
                TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
                template.save(emp1);
                transactionManager.commit(status);
               
                EmployeeImpl emp2 = (EmployeeImpl) template.get(EmployeeImpl.class, emp1.getId());
               
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

  protected abstract PlatformTransactionManager getPlatformTransactionManager();
 
  protected abstract UserDao getUserDao();
 
  private void startTx() {
    this.transactionStatus = getPlatformTransactionManager().getTransaction(new DefaultTransactionDefinition());
  }
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

  @Test
  public void testGetConnectionInTx() throws java.sql.SQLException {
    TransactionStatus status = null;

    try {
      status = txManager.getTransaction(new DefaultTransactionDefinition());

      java.sql.Connection con = sqlSessionTemplate.getConnection();

      assertFalse(con.isClosed());
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

    DataSourceTransactionManager manager = new DataSourceTransactionManager(dataSource);

    TransactionStatus status = null;

    try {
      status = manager.getTransaction(new DefaultTransactionDefinition());

      // will synchronize the template with the current tx
      template.getConnection();

      SqlSessionHolder holder = (SqlSessionHolder) TransactionSynchronizationManager
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

  }

  @Test
  public void testWithTxRequired() {
    DefaultTransactionDefinition txDef = new DefaultTransactionDefinition();
    txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED");

    TransactionStatus status = txManager.getTransaction(txDef);

    sqlSessionTemplate.getMapper(TestMapper.class).findTest();
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

    }
  }

  @Test
  public void testWithTx() throws Exception {
    TransactionStatus status = txManager.getTransaction(new DefaultTransactionDefinition());

    find();

    txManager.commit(status);
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

    sqlSessionFactory.getConfiguration().setEnvironment(nonSpring);

    TransactionStatus status = null;

    try {
      status = txManager.getTransaction(new DefaultTransactionDefinition());

      find();

      fail("should not be able to get an SqlSession using non-Spring tx manager when there is an active Spring tx");
    } finally {
View Full Code Here

Examples of org.springframework.transaction.support.DefaultTransactionDefinition

    SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory);

    TransactionStatus status = null;

    try {
      status = txManager.getTransaction(new DefaultTransactionDefinition());

      find(sqlSessionTemplate);

      txManager.commit(status);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.