Announcement Announcement Module
Collapse
No announcement yet.
Why can I only use one transaction per thread when using DataSourceTransactionManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why can I only use one transaction per thread when using DataSourceTransactionManager

    Hello everyone,

    I am currently evaluating and learning spring which I am going to use to improve a complex application which is using a legacy connection pool implementation which has several limitations.

    Because our applications' code base is both used for a web application and stand alone applications, I want to support local transactions as well as container managed transactions (via JNDI). My first approach is to get the system running using local transaction, which are managed by Spring.

    I read the documentation and API docuementation, and I am thinking DataSourceTransactionManager is the right way to go.
    But one thing makes me pensive:

    "Binds a JDBC Connection from the specified DataSource to the current thread, potentially allowing for one thread-bound Connection per DataSource"

    Why was this limitation implemented? How to break this limitation? We have serveral classes which require multiple transaction on the same datasource within one thread?

    For further information (and references to good spring jdbc tutorials) I would be very thankfully.

    Best Regards,
    Patric

  • #2
    The fact that there is 1 connection DOESN'T mean that there cannot be more transactions!.

    Also by multiple transactions do you mean at the same time or sequentially?

    Comment


    • #3
      You are right, thats the exactly the way our software works currently. I have one Connection, but many transactions at the same time within one thread.

      But the Spring tells me that I cannot do this with DataSourceTransactionManager.
      Why?

      Comment


      • #4
        But the Spring tells me that I cannot do this with DataSourceTransactionManager.
        It is stated nowhere in the documentation. It only states that you have 1 connection per thread. It mentions nothing about the fact that you are limited to 1 transaction! So I'm not sure where you get this idea....

        Comment


        • #5
          Originally posted by Marten Deinum View Post
          It is stated nowhere in the documentation. It only states that you have 1 connection per thread. It mentions nothing about the fact that you are limited to 1 transaction! So I'm not sure where you get this idea....
          You are right. I mixed up connection with transaction. Thank you for outlining this and I am sorry that I wasted your time.

          Comment

          Working...
          X