本文整理匯總了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;
}