org.springframework.orm.hibernate5.HibernateTransactionManager Java Examples

The following examples show how to use org.springframework.orm.hibernate5.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: 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: SpringHibernateTransactionOperations.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * 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 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 #4
Source File: AppConfig.java    From Building-Web-Apps-with-Spring-5-and-Angular with MIT License 5 votes vote down vote up
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(
        SessionFactory sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(
            sessionFactory);
    return transactionManager;
}
 
Example #5
Source File: AppConfig.java    From Building-Web-Apps-with-Spring-5-and-Angular with MIT License 5 votes vote down vote up
@Bean(name = "transactionManager")
public HibernateTransactionManager getTransactionManager(
        SessionFactory sessionFactory) {
    HibernateTransactionManager transactionManager = new HibernateTransactionManager(
            sessionFactory);
    return transactionManager;
}
 
Example #6
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 #7
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 #8
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 #9
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 #10
Source File: Hibernate5Config.java    From spring4-sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	return new HibernateTransactionManager(sessionFactory());
}
 
Example #11
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 #12
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 #13
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 #14
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 #15
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 #16
Source File: HibernateSpringConfigurer.java    From micro-server with 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 #17
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 #18
Source File: InfrastructureConfig.java    From Learning-Path-Spring-5-End-to-End-Programming with MIT License 4 votes vote down vote up
@Bean //implementation
public PlatformTransactionManager transactionManager(SessionFactory sessionFactory){
	return new HibernateTransactionManager(sessionFactory);
}
 
Example #19
Source File: TestDataConfig.java    From Spring with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
    return new HibernateTransactionManager(sessionFactory());
}
 
Example #20
Source File: TestDataConfig.java    From Spring with Apache License 2.0 4 votes vote down vote up
@Bean
public PlatformTransactionManager transactionManager() {
	return new HibernateTransactionManager(sessionFactory());
}
 
Example #21
Source File: HibernateConfiguration.java    From butterfly with Apache License 2.0 4 votes vote down vote up
@Bean
public HibernateTransactionManager hibernateTransactionManager(final SessionFactory sessionFactory){
    return new HibernateTransactionManager(sessionFactory);
}