Java Code Examples for org.springframework.orm.hibernate5.HibernateTransactionManager#setSessionFactory()

The following examples show how to use org.springframework.orm.hibernate5.HibernateTransactionManager#setSessionFactory() . 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: TransactionManagerHolder.java    From framework with 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
Source File: HiberConfig.java    From Spring-5.0-Cookbook with 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 3
Source File: HibernateConfig.java    From spring4-hibernate5-example with 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 4
Source File: HibernateConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Bean
public PlatformTransactionManager hibernateTransactionManager()
    throws Exception
{
    HibernateTransactionManager transactionManager = new HibernateTransactionManager();
    transactionManager.setSessionFactory( sessionFactory().getObject() );
    transactionManager.setDataSource( dataSource() );
    return transactionManager;
}
 
Example 5
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 6
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 7
Source File: DatabaseConfig.java    From spring-security-jwt-rest-stateless with MIT License 4 votes vote down vote up
@Bean
public HibernateTransactionManager transactionManager() {
    HibernateTransactionManager manager = new HibernateTransactionManager();
    manager.setSessionFactory(hibernate5SessionFactoryBean().getObject());
    return manager;
}
 
Example 8
Source File: HibernateConf.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 9
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 10
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 11
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 12
Source File: HibernateConf.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;
}