Announcement Announcement Module
No announcement yet.
One connection in same transaction? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • One connection in same transaction?

    I am trying to understand and figure out if spring manages to return the same connection instance whenever any number of database operations are performed in one transaction.

    While reading spring source code I had a look at TransactionSynchronizationManager and found that it maintains a thread local map of data source and the connection instance.

    Is it true that this is how spring manages to return the same instance of the connection for a given datasource in one transaction? (The reason I mention "a given data source" is to also account for distributed transaction)

    Returning the same connection is especially important when isolation level is changed on a connection instance. Are there any other scenarios/use cases where it does not make sense to use multiple connection instances in the same transaction? i.e. to understand what goes wrong if multiple connection instances are used in the same transaction?