Package org.springframework.jdbc.datasource

Examples of org.springframework.jdbc.datasource.DataSourceTransactionManager


        return new DaoImpl();
    }

    @org.springframework.context.annotation.Bean
    public PlatformTransactionManager myTransactionManager() {
        return new DataSourceTransactionManager(dataSource());
    }
View Full Code Here


    /**
     * Creates the transaction template
     */
    protected static TransactionTemplate createTransactionTemplate(DataSource dataSource) {
        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        return transactionTemplate;
    }
View Full Code Here

    return new CommentWithUserRepository(new TableDescription("COMMENTS", "COMMENTS JOIN USERS ON COMMENTS.user_name = USERS.user_name", "id"));
  }

  @Bean
  public PlatformTransactionManager transactionManager() {
    return new DataSourceTransactionManager(dataSource());
  }
View Full Code Here

    userRepository.setDataSource(dataSource);
    userRepository.setSqlGenerator(new SqlGenerator());

    //and
    final TransactionOperations tx = new TransactionTemplate(
        new DataSourceTransactionManager(dataSource));

    //when
    final List<User> users = tx.execute(new TransactionCallback<List<User>>() {
      @Override
      public List<User> doInTransaction(TransactionStatus status) {
View Full Code Here

       
        db = new EmbeddedDatabaseBuilder()
            .setType(EmbeddedDatabaseType.DERBY).build();
        reg.bind("testdb", db);
       
        DataSourceTransactionManager txMgr = new DataSourceTransactionManager();
        txMgr.setDataSource(db);
        reg.bind("txManager", txMgr);
       
        SpringTransactionPolicy txPolicy = new SpringTransactionPolicy();
        txPolicy.setTransactionManager(txMgr);
        txPolicy.setPropagationBehaviorName("PROPAGATION_REQUIRED");
View Full Code Here

    /**
     * Creates the transaction template
     */
    protected static TransactionTemplate createTransactionTemplate(DataSource dataSource) {
        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        return transactionTemplate;
    }
View Full Code Here

              .getProperty("db.driver");
        }
        dataSource = new SimpleDriverDataSource((Driver) Class.forName(
            dbDriver).newInstance(), dbURL);
        txTemplate = new TransactionTemplate(
            new DataSourceTransactionManager(dataSource));
      } catch (InstantiationException e) {
        throw new ResourceInitializationException(e);
      } catch (IllegalAccessException e) {
        throw new ResourceInitializationException(e);
      } catch (ClassNotFoundException e) {
View Full Code Here

   * Returns a transaction manager to be used to create transactions.
   *
   * @return The transaction manager to be used to create transactions.
   */
  public PlatformTransactionManager getTransactionManager() {
    return new DataSourceTransactionManager(dataSource);
  }
View Full Code Here

   *         There was a problem initializing one of the DAOs.
   */
  private final void initDaos(final SqlDaoInterface... daoInterfaces) {
    // Create a transaction manager.
    PlatformTransactionManager transactionManager =
      new DataSourceTransactionManager(dataSource);
   
    // Create a new transaction definition and name it.
    DefaultTransactionDefinition transactionDefinition =
      new DefaultTransactionDefinition();
    transactionDefinition
      .setName("Initializing the Open mHealth DAO database tables.");
   
    // Create the new transaction.
    TransactionStatus transactionStatus =
      transactionManager.getTransaction(transactionDefinition);
   
    // Create the table if it does not exist.
    try {
      for(SqlDaoInterface daoInterface : daoInterfaces) {
        // Create the table if it does not exist.
        jdbcTemplate.execute(daoInterface.getSqlTableDefinition());
      }
    }
    // If creating the table fails, roll back the transaction and error
    // out.
    catch(DataAccessException e) {
      transactionManager.rollback(transactionStatus);
      throw
        new IllegalStateException(
          "There was an issue creating a DAO table definition.",
          e);
    }
   
    // TODO: This is where the DAO interface's update scripts would
    // be run.
   
    // Commit the transaction.
    try {
      transactionManager.commit(transactionStatus);
    }
    catch(TransactionException e) {
      transactionManager.rollback(transactionStatus);
      throw
        new IllegalStateException(
          "There was an error committing the transaction.",
          e);
    }
View Full Code Here

    /**
     * Creates the transaction template
     */
    protected static TransactionTemplate createTransactionTemplate(DataSource dataSource) {
        TransactionTemplate transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(dataSource));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        return transactionTemplate;
    }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.datasource.DataSourceTransactionManager

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.