當前位置: 首頁>>代碼示例>>Java>>正文


Java JpaTransactionManager.setDataSource方法代碼示例

本文整理匯總了Java中org.springframework.orm.jpa.JpaTransactionManager.setDataSource方法的典型用法代碼示例。如果您正苦於以下問題:Java JpaTransactionManager.setDataSource方法的具體用法?Java JpaTransactionManager.setDataSource怎麽用?Java JpaTransactionManager.setDataSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.orm.jpa.JpaTransactionManager的用法示例。


在下文中一共展示了JpaTransactionManager.setDataSource方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: transactionManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setDataSource(dataSourceH2());
    txManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return txManager;
}
 
開發者ID:rumatoest,項目名稱:jdblender,代碼行數:8,代碼來源:Config.java

示例2: transactionManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
@Bean
public PlatformTransactionManager transactionManager() {
    JpaTransactionManager txManager = new JpaTransactionManager();
    txManager.setEntityManagerFactory(this.entityManagerFactory);
    txManager.setDataSource(this.dataSource);
    return txManager;
}
 
開發者ID:wswenyue,項目名稱:taolijie,代碼行數:8,代碼來源:EmbededDatabaseBeanConfig.java

示例3: herdTransactionManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
/**
 * Our Spring JPA transaction manager that will manage the JPA transactions.
 *
 * @return the JPA transaction manager.
 */
@Bean
public JpaTransactionManager herdTransactionManager()
{
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setDataSource(getHerdDataSource());
    transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
    return transactionManager;
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:14,代碼來源:DaoSpringModuleConfig.java

示例4: transactionManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
@Bean
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
	JpaTransactionManager jtm = new JpaTransactionManager(emf);
	jtm.setDataSource(dataSource());
	return jtm;
}
 
開發者ID:holon-platform,項目名稱:holon-datastore-jpa-querydsl,代碼行數:7,代碼來源:TestJpaQueryDslDatastoreHibernate.java

示例5: txManager

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
@Bean
public JpaTransactionManager txManager(DataSource dataSource) {
  JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
  jpaTransactionManager.setDataSource(dataSource);
  return jpaTransactionManager;
}
 
開發者ID:puncha,項目名稱:petclinic,代碼行數:7,代碼來源:WebConfig.java

示例6: init

import org.springframework.orm.jpa.JpaTransactionManager; //導入方法依賴的package包/類
/**
 * Initializes the hypersonic db.
 */
public synchronized void init(String... packagesToScan) {
    if (ArrayUtils.isEmpty(packagesToScan)) {
        throw new RuntimeException("Package names to scan must be provided as arg");
    }

    if (isInitialized()) {
        //If already initialized just return cleanly
        return;
    }

    try {
        dataSource = new BasicDataSource();
        dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
        dataSource.setUrl("jdbc:hsqldb:mem:sprite");
        dataSource.setUsername("sa");
        dataSource.setPassword("");

        JpaDialect dialect = new HibernateJpaDialect();
        LocalContainerEntityManagerFactoryBean localEMFactory = new LocalContainerEntityManagerFactoryBean();

        localEMFactory.setJpaDialect(dialect);
        localEMFactory.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
        localEMFactory.setDataSource(dataSource);
        localEMFactory.setPackagesToScan(packagesToScan);

        //localEMFactory.setLoadTimeWeaver(new InstrumentationLoadTimeWeaver());
        Map<String, Object> properties = new HashMap<String, Object>();

        properties.put("eclipselink.logging.level", "FINE");
        properties.put("eclipselink.logging.level.sql", "FINE");
        properties.put("hibernate.hbm2ddl.auto", "create-drop");
        properties.put("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
        properties.put("PersistenceVersion", "2.1");
        localEMFactory.setJpaPropertyMap(properties);

        localEMFactory.afterPropertiesSet();

        entityManagerFactory = localEMFactory.getObject();
        jdbcTemplate = new JdbcTemplate(dataSource);

        transactionManager = new JpaTransactionManager();
        transactionManager.setJpaDialect(dialect);
        transactionManager.setEntityManagerFactory(entityManagerFactory);
        transactionManager.setDataSource(dataSource);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Failed to initialize entityManager: " + ex);
    }

    initialized = true;
}
 
開發者ID:cucina,項目名稱:opencucina,代碼行數:55,代碼來源:HsqlDb.java


注:本文中的org.springframework.orm.jpa.JpaTransactionManager.setDataSource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。