Announcement Announcement Module
Collapse
No announcement yet.
Single Transaction Manager with Multiple DAOs Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Single Transaction Manager with Multiple DAOs

    Hello,

    I have the following situation. I have an web service endpoint with a method that has been annotated with @Transactional. The transaction manager points to a data source called X. Within the endpoint method, I have two different DAOs. One of the DAOs uses a NamedParameterJdbcTemplate (that points to data source X) and the other DAO uses a SimpleJdbcInsert (that also points to data source X).

    My question is, will the operations of both DAOs fall under the same transaction even if the operations are being performed by two separate templates that are both pointing to the same data source?

    Please note that both DAOs as well as the transaction manager are all pointing to the same data source instance.

    Thank you.

  • #2
    The transaction should be on the service layer NOT the dao layer, if you do this everything will participate in a single transaction. If you don't do this you will get 2 transactions as it are 2 individual method calls outside of a shared transaction.

    Comment

    Working...
    X