本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}