Java Code Examples for org.springframework.orm.hibernate5.HibernateTransactionManager

The following examples show how to use org.springframework.orm.hibernate5.HibernateTransactionManager. These examples are extracted from open source projects. 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 Project: framework   Source File: TransactionManagerHolder.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Description: 获取Spring trascation <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @return <br>
 */
public static PlatformTransactionManager getTransactionManager() {

    synchronized (transactionManagerHolder) {
        String dbCode = DynamicDataSourceManager.getDataSourceCode();
        PlatformTransactionManager manager = transactionManagerHolder.get(dbCode);

        if (manager == null) {
            HibernateTransactionManager hibernateTransactionManager = new HibernateTransactionManager();
            hibernateTransactionManager.setSessionFactory(getSessionFactory());
            manager = hibernateTransactionManager;
            transactionManagerHolder.put(dbCode, manager);
        }

        return manager;
    }
}
 
Example 2
/**
 * Default constructor.
 * @param hibernateTransactionManager The hibernate transaction manager.
 */
protected SpringHibernateTransactionOperations(HibernateTransactionManager hibernateTransactionManager) {
    this.sessionFactory = hibernateTransactionManager.getSessionFactory();
    this.transactionManager = hibernateTransactionManager;
    this.writeTransactionTemplate = new TransactionTemplate(hibernateTransactionManager);
    DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition();
    transactionDefinition.setReadOnly(true);
    this.readTransactionTemplate = new TransactionTemplate(hibernateTransactionManager, transactionDefinition);
}
 
Example 3
Source Project: Spring-5.0-Cookbook   Source File: HiberConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager db1TransactionManager(DataSource dataSource,LocalSessionFactoryBean localSessionFactory) {
       HibernateTransactionManager txManager = new HibernateTransactionManager();
       txManager.setSessionFactory(localSessionFactory.getObject());
       txManager.setDataSource(dataSource);
       return txManager;
}
 
Example 4
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(
        SessionFactory sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(
            sessionFactory);
    return transactionManager;
}
 
Example 5
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(
        SessionFactory sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(
            sessionFactory);
    return transactionManager;
}
 
Example 6
Source Project: spring4-hibernate5-example   Source File: HibernateConfig.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize Transaction Manager
 * 
 * @param sessionFactory
 * @return HibernateTransactionManager
 */
@Bean
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
	HibernateTransactionManager txManager = new HibernateTransactionManager();
	txManager.setSessionFactory(sessionFactory);
	return txManager;
}
 
Example 7
@Bean
public PlatformTransactionManager hibernateTransactionManager()
    throws Exception
{
    HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory( sessionFactory().getObject() );
    transactionManager.setDataSource( dataSource() );
    return transactionManager;
}
 
Example 8
Source Project: tutorials   Source File: PersistenceConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    final HibernateTransactionManager txManager = new HibernateTransactionManager();
    txManager.setSessionFactory(sessionFactory().getObject());

    return txManager;
}
 
Example 9
Source Project: quickperf   Source File: SpringConfig.java    License: 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 10
Source Project: butterfly   Source File: HibernateConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public HibernateTransactionManager hibernateTransactionManager(final SessionFactory sessionFactory){
    return new HibernateTransactionManager(sessionFactory);
}
 
Example 11
Source Project: Spring   Source File: TestDataConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	return new HibernateTransactionManager(sessionFactory());
}
 
Example 12
Source Project: Spring   Source File: TestDataConfig.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    return new HibernateTransactionManager(sessionFactory());
}
 
Example 13
@Bean //implementation
public PlatformTransactionManager transactionManager(SessionFactory sessionFactory){
	return new HibernateTransactionManager(sessionFactory);
}
 
Example 14
@Bean
public HibernateTransactionManager transactionManager() {
    HibernateTransactionManager manager = new HibernateTransactionManager();
    manager.setSessionFactory(hibernate5SessionFactoryBean().getObject());
    return manager;
}
 
Example 15
Source Project: micro-server   Source File: HibernateSpringConfigurer.java    License: Apache License 2.0 4 votes vote down vote up
private HibernateTransactionManager buildTransactionManager(String name, Config config, DataSource dataSource, JdbcConfig jdbc) {
	return HibernateSessionBuilder.builder().packages(config.getDataSources().getOrElse(name, Arrays.asList())).dataSource(dataSource).env(jdbc).build()
			.transactionManager();
}
 
Example 16
Source Project: tutorials   Source File: HibernateConf.java    License: MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
 
Example 17
Source Project: tutorials   Source File: PersistenceConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
 
Example 18
Source Project: tutorials   Source File: PersistenceConfig.java    License: MIT License 4 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager() {
    final HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory(sessionFactory().getObject());
    return transactionManager;
}
 
Example 19
Source Project: tutorials   Source File: PersistenceConfig.java    License: 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 Project: tutorials   Source File: HibernateConf.java    License: 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 Project: spring4-sandbox   Source File: Hibernate5Config.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	return new HibernateTransactionManager(sessionFactory());
}