Announcement Announcement Module
Collapse
No announcement yet.
Does using DataSource proxy has any performance overhead? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does using DataSource proxy has any performance overhead?

    Question -

    I want to understand if using DataSource proxy ( created using TransactionAwareDataSourceProxy class) has any performance overhead?

    Spring Documentation for TransactionAwareDataSourceProxy explicitly mentions -
    Note that the transaction manager, for example DataSourceTransactionManager, still needs to work with the underlying DataSource, not with this proxy.
    But there is no mention of what happens when we create a Spring JDBC template using a DataSource proxy. Will Spring JDBC template also work with underlying DataSource and not with this proxy?


    Requirement -

    In order to cater our business requirements, we plan to use Spring JDBC template for most of the cases. But we also want the flexibility to use plain JDBC per-need basis when there is a use case. So we need our transaction architecture to support both Spring JDBC Template and Plain JDBC together within the same transaction scope.

    As per my understanding,

    1. By default, Spring framework will not manage transactions for plain-JDBC code, even when we get JDBC connection from the same data source which is managed by Spring transaction manager.

    2. In order to use both Spring JDBC Template and Plain JDBC together within the same transaction, we will need to create a proxy for our DataSource (using TransactionAwareDataSourceProxy class). This will ensure that all operations performed through plain (standard) JDBC will now participate in Spring-managed transactions.

    3. We also explored the option, if we could continue using DataSource with Spring JDBC template, and use DataSource proxy ONLY with plain-JDBC code. But we found out that Spring does not manage transactions across DataSource and DataSource proxy created with the same DataSource.
Working...
X