Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Spring and threads – transactions

Pragya Keshap answered on February 20, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • The best way to use the Spring Transactional annotation
  • What are the benefits provided by Spring Framework’s Transaction Management?
  • @Transactional how to monitor the existing transactions in my spring boot application

  • Spring and threads – transactions

    0

    The Spring Framework offers an extensive API for database transaction management. Spring takes care of all basic transaction management control and provides a consistent programming model for different transaction APIs, such as JDBC, Hibernate, Java Transaction API (JTA), Java Persistence API (JPA), and Java Data Objects (JDO). There are two types of transactions provided by Spring: one is declarative and the other is programmatic transaction management. Declarative is very high-level, while programmatic is more advanced but flexible.

    Spring transaction management works very well with a single thread. But it cannot manage a transaction across multiple threads. If we try to use the transaction with multiple threads, our program gives a runtime error or an unexpected result.

    To understand why a Spring transaction fails with multiple threads, first, we need to understand how transactions work with Spring. Spring stores all transaction information in the ThreadLocal variables inside the org.springframework.transaction.support.TransactionSynchronizationManager class:

    https://dzone.com/articles/spring-transaction-management-over-multiple-thread-1

    Popularity 1/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 20 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.