Prev Next

Spring / Spring Data Access

Can I use multiple transaction managers within a spring application?

Yes. @Transactional annotation has the property transactionManager which can be set to specify which transaction manager to be used.

<bean id="transactionManager1"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory1" />
    <qualifier value="TM1"/>
</bean>

<bean id="transactionManager2"
    class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory2" />
    <qualifier value="TM2"/>
</bean>

public class DAOService {

    @Transactional("TM1")
    public void doSomethingWithTransactionManager1() { ... }

    @Transactional("TM2")
    public void doSomethingWithTransactionManager2(() { ... }
}

It's right time to invest in Cryptocurrencies Dogecoin! Earn free bitcoins up to $250 now by signing up.

Earn bitcoins upto $250 (free), invest in other Cryptocurrencies when you signup with blockfi. Use the referral link: Signup now and earn!

Using BlockFi, don't just buy crypto - start earning on it. Open an interest account with up to 8.6% APY, trade currencies, or borrow money without selling your assets.


Join CoinBase! We'll both receive $10 in free Bitcoin when they buy or sell their first $100 on Coinbase! Available in India also. Use the referral Join coinbase!


Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

Explain JdbcTemplate in Spring framework. Advantages of Spring JDBC Template over standard JDBC. How could I access Hibernate using Spring? How can we integrate Spring and Hibernate using HibernateDaoSupport? What are the advantages of transaction management in Spring Framework? Which Transaction management type is preferred in Spring? Explain DataAccessException in Spring. How do I configure DAO in Spring? What are the ORMs does Spring supports? List some of the no sql databases does spring support? Give few examples of spring callbacks used in JdbcTemplate. Difference between Spring Data-JPA versus JPA. What is Spring Data JPA? What are the exceptions thrown by the Spring DAO classes? What is SQLExceptionTranslator in Spring DAO? Difference between CrudRepository and JpaRepository interfaces in Spring Data JPA. Difference between Spring Data JPA and hibernate. How do I decide between JPA and Spring JdbcTemplate? What is PreparedStatementCreator in Spring Data framework? What is SQLProvider in Spring Data framework? What is BatchPreparedStatementSetter in Spring Data? Which is the better way of using JDBC in Spring? What template does Spring JDBC provide to access database? What are the native NativeJdbcExtractor in Spring? Explain Global and Local transactions in Spring. How do we roll back a declarative transaction in Spring? Different types of isolation in spring transaction management. Types of propagation in Spring transaction management. Spring: How do I rollback a declarative transaction? Spring: List out the role of TransactionDefinition interface. What are the benefits of the Spring transaction management ? Why Spring Declarative transaction management is preferred over programmatic? Spring @Transactional Annotation. What is the principle of Declarative transaction management in Spring? How does @Transactional works in Spring? How do you prevent SQL Injection in Java Code? Advantages of using @RepositoryRestResource annotation in Spring Data REST. When to use @RestController vs @RepositoryRestResource annotations in Spring. How do I unit test spring data repositories? What are the different isolation levels of DBMS? What is the difference between serializable and repeatable read isolation level? Explain serializable isolation level. What is the ISOLATION_DEFAULT in spring transaction management. What is the default propagation behavior of spring transaction management? Does the transaction rollback on exception in spring declarative transaction management? Explain NoRepositoryBean spring annotation. How do you handle High-volume Transaction Processing in J2EE? Explain Dirty read. Difference between non-repeatable read and phantom read. What is 2 phase commit? Difference between JDBC and connection pooling. When to use JTA and JPA transaction manager? Can I use multiple transaction managers within a spring application? Difference between Spring JtaTransactionManager and HibernateTransactionManager. Difference between HibernateTransactionManager and JpaTransactionManager. Difference between DataSourceTransactionManager and HibernateTransactionManager. Does Spring Transactional annotation support both global and local transactions? is Spring transactional annotation be applied only for public methods? Why applying Spring Transactional annotation on the concrete class or its methods is recommended rater than on interface? Explain proxy-target-class attribute of spring transactions. What are the default @Transactional settings? What are the different Spring propagation levels? What is Spring Data? Describe the purpose of the @Transactional(propagation = Propagation.NESTED) annotation.
Show more question and Answers...

Spring AOP

Comments & Discussions