Spring Framework DataSourceTransactionManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework DataSourceTransactionManager class.

This code example shows how to use the following methods:commit, getTransaction, rollback
    private DataSourceTransactionManager transactionManager; 
 
    @Override 
    public Object invoke(MethodInvocation invocation) throws Throwable { 
        DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(); 
        TransactionStatus transaction = transactionManager.getTransaction(transactionDefinition); 
 
        try { 
            Object result = invocation.proceed(); 
 
            try { 
                if (transaction.isNewTransaction()) 
                    transactionManager.commit(transaction); 
            } 
            catch (UnexpectedRollbackException ignore) {} 
 
            return result; 
        } 
        catch (Exception e) { 
            if (transaction.isNewTransaction()) 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTransaction, rollback
			this.jdbcTemplate.queryForList("select * from test;").toString()); 
	} 
	 
	@Test 
	public void disableSpringTransaction() throws Exception { 
		DataSourceTransactionManager tm = new DataSourceTransactionManager(this.dataSource); 
		 
		TransactionStatus ts = tm.getTransaction(null); 
		Connection notTransactional = this.dataSource.getConnection(); 
		RdbUtils.deleteAll(notTransactional, "test"); 
		tm.rollback(ts); 
		 
		assertTrue(this.jdbcTemplate.queryForList("select * from test;").isEmpty()); 
	} 
	 
	@Test 
	public void enableSpringTransaction() throws Exception { 
		DataSourceTransactionManager tm = new DataSourceTransactionManager(this.dataSource); 
		 
		TransactionStatus ts = tm.getTransaction(null); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
@Configuration 
public class EmptyDatabaseConfig { 
 
	@Bean 
	public PlatformTransactionManager transactionManager() { 
		return new DataSourceTransactionManager(dataSource()); 
	} 
 
	@Bean 
	public DataSource dataSource() { 
		return new EmbeddedDatabaseBuilder()// 
		.setName("empty-sql-scripts-test-db")// 
		.build(); 
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
@Configuration 
public class PopulatedSchemaDatabaseConfig { 
 
	@Bean 
	public PlatformTransactionManager transactionManager() { 
		return new DataSourceTransactionManager(dataSource()); 
	} 
 
	@Bean 
	public DataSource dataSource() { 
		return new EmbeddedDatabaseBuilder()// 
		.setName("populated-sql-scripts-test-db")// 
		.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") // 
		.build(); 
	} 
 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
			return employee; 
		} 
 
		@Bean 
		public PlatformTransactionManager transactionManager() { 
			return new DataSourceTransactionManager(dataSource()); 
		} 
 
		@Bean 
		public DataSource dataSource() { 
			return new EmbeddedDatabaseBuilder()// 
			.addScript("classpath:/org/springframework/test/context/junit4/spr9051/schema.sql")// 
			// Ensure that this in-memory database is only used by this class: 
			.setName(getClass().getName())// 
			.build(); 
		} 
 
	} 
 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDataSource
    return ds; 
  } 
 
  @Bean(name = "transactionManager") 
  public PlatformTransactionManager annotationDrivenTransactionManager() { 
    DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(); 
    transactionManager.setDataSource(dataSource()); 
    return transactionManager; 
  } 
   
  @Bean(name="processEngineFactoryBean") 
  public ProcessEngineFactoryBean processEngineFactoryBean() { 
    ProcessEngineFactoryBean factoryBean = new ProcessEngineFactoryBean(); 
    factoryBean.setProcessEngineConfiguration(processEngineConfiguration()); 
    return factoryBean; 
  } 
   
  @Bean(name="processEngine") 
  public ProcessEngine processEngine() { 
    // Safe to call the getObject() on the @Bean annotated processEngineFactoryBean(), will be 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDataSource
		return ds; 
	} 
 
	@Bean 
	public PlatformTransactionManager transactionManager() { 
		DataSourceTransactionManager txManager = new DataSourceTransactionManager(); 
		txManager.setDataSource(dataSource()); 
		return txManager; 
	} 
} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	@Configuration 
	static class Config { 
 
		@Bean 
		public PlatformTransactionManager txMgr1() { 
			return new DataSourceTransactionManager(dataSource1()); 
		} 
 
		@Bean 
		public PlatformTransactionManager txMgr2() { 
			return new DataSourceTransactionManager(dataSource2()); 
		} 
 
		@Bean 
		public DataSource dataSource1() { 
			return new EmbeddedDatabaseBuilder()// 
			.setName("database1")// 
			.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// 
			.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// 
			.build(); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	@Configuration 
	static class Config { 
 
		@Bean 
		public PlatformTransactionManager txMgr1() { 
			return new DataSourceTransactionManager(dataSource1()); 
		} 
 
		@Bean 
		public PlatformTransactionManager txMgr2() { 
			return new DataSourceTransactionManager(dataSource2()); 
		} 
 
		@Bean 
		public DataSource dataSource1() { 
			return new EmbeddedDatabaseBuilder()// 
			.setName("database1")// 
			.addScript("classpath:/org/springframework/test/context/jdbc/schema.sql")// 
			.addScript("classpath:/org/springframework/test/context/jdbc/data.sql")// 
			.build(); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:afterPropertiesSet, setDataSource
 
        final ConnectionFactory connectionFactory = new ConnectionFactory(); 
        connectionFactory.setDataSource( this.dataSource ); 
        connectionFactory.setDecorator( new DialectConnectionDecorator( dialect ) ); 
 
        final DataSourceTransactionManager txManager = new DataSourceTransactionManager(); 
        txManager.setDataSource( this.dataSource ); 
        txManager.afterPropertiesSet(); 
 
        final TransactionTemplate txTemplate = new TransactionTemplate(); 
        txTemplate.setTransactionManager( txManager ); 
        txTemplate.afterPropertiesSet(); 
 
        final StandardPropertyResolver propertyResolver = new StandardPropertyResolver(); 
        propertyResolver.setHomeDir( this.homeDir ); 
        propertyResolver.afterPropertiesSet(); 
 
        final UpgradeServiceImpl upgradeService = new UpgradeServiceImpl(); 
        upgradeService.setDialect( dialect ); 
        upgradeService.setConnectionFactory( connectionFactory ); 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Spring Framework DataSourceTransactionManager Methods: