本文整理汇总了Java中org.springframework.orm.hibernate5.HibernateTransactionManager.setDataSource方法的典型用法代码示例。如果您正苦于以下问题:Java HibernateTransactionManager.setDataSource方法的具体用法?Java HibernateTransactionManager.setDataSource怎么用?Java HibernateTransactionManager.setDataSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.orm.hibernate5.HibernateTransactionManager
的用法示例。
在下文中一共展示了HibernateTransactionManager.setDataSource方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.orm.hibernate5.HibernateTransactionManager; //导入方法依赖的package包/类
/**
*/
@Before
public void setUp() {
final DataSource ds = new DriverManagerDataSource(System.getProperty("jdbc.url", "jdbc:sap://localhost:30115"),
System.getProperty("jdbc.user", "hibernate"), System.getProperty("jdbc.password", "hibernate"));
final LocalSessionFactoryBuilder builder = new LocalSessionFactoryBuilder(ds);
builder.setProperty(AvailableSettings.DIALECT,
System.getProperty("hibernate.dialect", HANAColumnStoreDialect.class.getName()));
builder.setProperty(AvailableSettings.HBM2DDL_AUTO, "create-drop");
builder.setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
builder.addAnnotatedClass(Employee.class);
this.sessionFactory = builder.buildSessionFactory();
final HibernateTemplate ht = new HibernateTemplate();
ht.setSessionFactory(this.sessionFactory);
ht.afterPropertiesSet();
this.template = ht;
final HibernateTransactionManager txnMgr = new HibernateTransactionManager();
txnMgr.setDataSource(ds);
txnMgr.setSessionFactory(this.sessionFactory);
txnMgr.afterPropertiesSet();
this.transactionTemplate = new TransactionTemplate(txnMgr);
}
示例2: db1TransactionManager
import org.springframework.orm.hibernate5.HibernateTransactionManager; //导入方法依赖的package包/类
@Bean
public HibernateTransactionManager db1TransactionManager(DataSource dataSource,LocalSessionFactoryBean localSessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(localSessionFactory.getObject());
txManager.setDataSource(dataSource);
return txManager;
}
示例3: txManager
import org.springframework.orm.hibernate5.HibernateTransactionManager; //导入方法依赖的package包/类
@Bean
public PlatformTransactionManager txManager() throws Exception {
HibernateTransactionManager returnVal = new HibernateTransactionManager(
hibernateConfig.sessionFactory());
returnVal.setDataSource(dataSourceConfig.dataSource());
return returnVal;
}
示例4: transactionManager
import org.springframework.orm.hibernate5.HibernateTransactionManager; //导入方法依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
final HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
txManager.setDataSource(dataSource());
return txManager;
}