org.springframework.orm.hibernate4.HibernateTransactionManager Java Examples

The following examples show how to use org.springframework.orm.hibernate4.HibernateTransactionManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Cause2PersistenceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #2
Source File: Cause4NonTransientConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #3
Source File: Cause5NonTransientConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #4
Source File: PersistenceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #5
Source File: GreetingServiceConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager(
		SessionFactory sessionFactory) {
	HibernateTransactionManager htm = new HibernateTransactionManager();
	htm.setSessionFactory(sessionFactory);
	return htm;
}
 
Example #6
Source File: GreetingServiceConfig.java    From blog with Apache License 2.0 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager(
		SessionFactory sessionFactory) {
	HibernateTransactionManager htm = new HibernateTransactionManager();
	htm.setSessionFactory(sessionFactory);
	return htm;
}
 
Example #7
Source File: SiteStatsTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public PlatformTransactionManager transactionManager() throws IOException {
    if (platformTransactionManager == null) {
        if (sessionFactory == null) {
            sessionFactory();
        }
        HibernateTransactionManager txManager = new HibernateTransactionManager();
        txManager.setSessionFactory(sessionFactory);
        platformTransactionManager = txManager;
    }
    return platformTransactionManager;
}
 
Example #8
Source File: SiteStatsPersistenceConfig.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean(name = "org.sakaiproject.sitestats.SiteStatsTransactionManager")
public PlatformTransactionManager getSiteStatsTransactionManager() throws IOException {
    if (siteStatsTransactionManager == null) {
        String whichDb = serverConfigurationService.getString("sitestats.db", "internal");
        if ("external".equals(whichDb)) {
            HibernateTransactionManager tx = new HibernateTransactionManager();
            tx.setSessionFactory(getSiteStatsSessionFactory());
            siteStatsTransactionManager = tx;
        } else {
            siteStatsTransactionManager = globalTransactionManager;
        }
    }
    return siteStatsTransactionManager;
}
 
Example #9
Source File: ContextMappingConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager =  new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #10
Source File: Cause1NonTransientConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #11
Source File: Cause1PersistenceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #12
Source File: MulCommonBaseServiceParser.java    From zxl with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #13
Source File: SiteStatsTestConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public PlatformTransactionManager transactionManager() throws IOException {
    if (platformTransactionManager == null) {
        if (sessionFactory == null) {
            sessionFactory();
        }
        HibernateTransactionManager txManager = new HibernateTransactionManager();
        txManager.setSessionFactory(sessionFactory);
        platformTransactionManager = txManager;
    }
    return platformTransactionManager;
}
 
Example #14
Source File: SiteStatsPersistenceConfig.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean(name = "org.sakaiproject.sitestats.SiteStatsTransactionManager")
public PlatformTransactionManager getSiteStatsTransactionManager() throws IOException {
    if (siteStatsTransactionManager == null) {
        String whichDb = serverConfigurationService.getString("sitestats.db", "internal");
        if ("external".equals(whichDb)) {
            HibernateTransactionManager tx = new HibernateTransactionManager();
            tx.setSessionFactory(getSiteStatsSessionFactory());
            siteStatsTransactionManager = tx;
        } else {
            siteStatsTransactionManager = globalTransactionManager;
        }
    }
    return siteStatsTransactionManager;
}
 
Example #15
Source File: ContextMappingConfiguration.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Bean
@Autowired
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager =  new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #16
Source File: Cause3PersistenceConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example #17
Source File: DbmMultipleDatasource.java    From onetwo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #18
Source File: DbTestContext.java    From OpERP with MIT License 4 votes vote down vote up
/**
 * 
 * This is setting up the hibernate transaction manager
 * 
 */
@Bean
public HibernateTransactionManager hibernateTransactionManager(
		SessionFactory sessionFactory) {
	return new HibernateTransactionManager(sessionFactory);
}
 
Example #19
Source File: PersistenceConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
 
Example #20
Source File: PersistenceTestConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
 
Example #21
Source File: HibernateConfig.java    From spring4-sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	return new HibernateTransactionManager(sessionFactory());
}
 
Example #22
Source File: SpringConfig.java    From quickperf with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager(LocalSessionFactoryBean sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory.getObject());
    return transactionManager;
}
 
Example #23
Source File: MessageBundleTestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public PlatformTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #24
Source File: AssignmentTestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #25
Source File: HelpManagerImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * @param txManager The txManager to set.
 */
public void setTxManager(HibernateTransactionManager txManager)
{
	this.txManager = txManager;
}
 
Example #26
Source File: MessageBundleTestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public PlatformTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #27
Source File: AssignmentTestConfiguration.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
@Bean(name = "org.sakaiproject.springframework.orm.hibernate.GlobalTransactionManager")
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory);
    return txManager;
}
 
Example #28
Source File: HelpManagerImpl.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
/**
 * @param txManager The txManager to set.
 */
public void setTxManager(HibernateTransactionManager txManager)
{
	this.txManager = txManager;
}
 
Example #29
Source File: DbmMultipleDatasource.java    From onetwo with Apache License 2.0 4 votes vote down vote up
private boolean isHibernateTransactionManager(PlatformTransactionManager pt){
	if(!ClassUtils.isPresent("org.hibernate.SessionFactory", ClassUtils.getDefaultClassLoader())){
		return false;
	}
	return HibernateTransactionManager.class.isInstance(pt);
}
 
Example #30
Source File: RepositoryTestConfig.java    From Project with Apache License 2.0 4 votes vote down vote up
public PlatformTransactionManager annotationDrivenTransactionManager() {
  System.out.println(sessionFactory);
  HibernateTransactionManager transactionManager = new HibernateTransactionManager();
  transactionManager.setSessionFactory(sessionFactory);
  return transactionManager;
}