@EnableTransactionManagement annotation with 2 transaction managers

In your configuration class, use @EnableTransactionManagement annotation.

Define a transaction manager in this class as:

    @Bean(name="txName")
    public HibernateTransactionManager txName() throws IOException{
        HibernateTransactionManager txName= new HibernateTransactionManager();
        txName.setSessionFactory(...);
        txName.setDataSource(...);
        return txName;
   }

There on, in your class/method that executes transactional job(s), annotate as follows:

@Transactional("txName")

or

@Transactional(value = "txName")

This is how you would tie a name qualified transaction manager to wherever you need it. You can now have as many transaction managers as you want and use it accordingly wherever you need.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)