本文整理汇总了Java中org.springframework.orm.hibernate4.HibernateTransactionManager类的典型用法代码示例。如果您正苦于以下问题:Java HibernateTransactionManager类的具体用法?Java HibernateTransactionManager怎么用?Java HibernateTransactionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HibernateTransactionManager类属于org.springframework.orm.hibernate4包,在下文中一共展示了HibernateTransactionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
return txManager;
}
示例2: getTransactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Autowired
@Bean(name="transactionManager")
public HibernateTransactionManager getTransactionManager(SessionFactory sessionFactory)
{
System.out.println("--Transaction manager Object Creation--");
HibernateTransactionManager transactionManager=new HibernateTransactionManager(sessionFactory);
System.out.println("--Transaction manager Object Created--");
return transactionManager;
}
示例3: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory s) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(s);
return txManager;
}
示例4: getTransactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Autowired
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(SessionFactory sessionFactory)
{
HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
return transactionManager;
}
示例5: getTransactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Autowired
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
return transactionManager;
}
示例6: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
示例7: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
示例8: getCurrentDatasource
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
public DataSource getCurrentDatasource(){
if(!masterSlave)
return masterDatasource;
SwitcherInfo switcher = contextHolder.getContextAttribute(SwitcherInfo.CURRENT_SWITCHER_INFO);
DataSource ds = masterDatasource;
if(switcher==null || StringUtils.isBlank(switcher.getCurrentSwitcherName())){
return ds;
}
switch (switcher.getType()) {
case TransactionManager:
PlatformTransactionManager pt = (PlatformTransactionManager)Springs.getInstance().getBean(switcher.getCurrentSwitcherName());
if(isHibernateTransactionManager(pt)){
ds = ((HibernateTransactionManager)pt).getDataSource();
}else if(DataSourceTransactionManager.class.isInstance(pt)){
ds = ((DataSourceTransactionManager)pt).getDataSource();
}else{
throw new UnsupportedOperationException("TransactionManager: " + switcher.getCurrentSwitcherName());
}
break;
default:
String dsName = switcher.getCurrentSwitcherName();// + DATASOURCE_KEY;
if(datasources.containsKey(dsName))
ds = datasources.get(dsName);
break;
}
return ds;
}
示例9: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
示例10: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
示例11: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
public HibernateTransactionManager transactionManager() {
if (this.enabled) {
return new HibernateTransactionManager(this.sessionFactory()
.getObject());
}
return null;
}
示例12: executeSQL
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
/**
* @param testContext
* @param file
* @param slsce
*/
private void executeSQL(TestContext testContext, String file,
SingleLineSqlCommandExtractor slsce) {
BufferedReader br;
ClassPathResource cpr = getClassPathResource(file, testContext);
br = _getBr(cpr);
// File f = new File(scriptPath);
// FileReader fr = new FileReader(file);
final String[] commands = slsce.extractCommands(br);
if (commands == null) {
return;
}
final HibernateTransactionManager tm = getTransactionManager(testContext);
final TransactionTemplate tt = new TransactionTemplate(tm);
tt.execute(new TransactionCallbackWithoutResult() {
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
for (String s : commands) {
if (StringUtils.isInvalid(s)) {
continue;
}
SQLQuery sql = tm.getSessionFactory().getCurrentSession()
.createSQLQuery(s.trim());
sql.executeUpdate();
}
}
});
}
示例13: buildHibernateTransactionManagerBeanDefinition
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
private BeanDefinition buildHibernateTransactionManagerBeanDefinition(Element element, String name) {
AbstractBeanDefinition beanDefinition = new GenericBeanDefinition();
beanDefinition.setAttribute(ID_ATTRIBUTE, name + HIBERNATE_TRANSACTION_MANAGER_SUFFIX);
beanDefinition.setBeanClass(HibernateTransactionManager.class);
MutablePropertyValues propertyValues = new MutablePropertyValues();
propertyValues.add("sessionFactory", new RuntimeBeanReference(name + SESSION_FACTORY_SUFFIX));
beanDefinition.setPropertyValues(propertyValues);
return beanDefinition;
}
示例14: buildSessionFactory
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Override
public synchronized SessionFactory buildSessionFactory() {
try {
LOG.debug("Building new session factory");
SessionFactory real = configurationProvider.getConfiguration().buildSessionFactory(
this.serviceRegistryBuilder.buildServiceRegistry());
LOG.debug("Session factory created, creating new Transaction Manager to handle transactions");
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setDataSource(((DatasourceConnectionProviderImpl) ((SessionFactoryImplementor) real).getServiceRegistry()
.getService(ConnectionProvider.class)).getDataSource());
txManager.setSessionFactory(proxySessionFactory);
txManager.setValidateExistingTransaction(true);
txManager.afterPropertiesSet();
// The anotations at this point uses the new transaction manager
AnnotationTransactionAspect txAspect = AnnotationTransactionAspect.aspectOf();
txAspect.setTransactionManager(txManager);
LOG.debug("New transaction manager established to AnnotationTransactionAspect, now the annotations used the new Transaction Manager");
return real;
} catch (RuntimeException ex) {
LOG.error("Runtime exception when trying to create session factory.", ex);
throw ex;
}
}
示例15: transactionManager
import org.springframework.orm.hibernate4.HibernateTransactionManager; //导入依赖的package包/类
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}