Announcement Announcement Module
Collapse
No announcement yet.
Nested transaction question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nested transaction question

    Hello,

    I want to make nested transactions with the DataSourceTransactionManager.
    I have DAO-Code that uses the TransactionTemplate with the DataSourceTransactionManager.
    Normally the transaction is done in the DAO for the JSF application.
    But I want to reuse the code from a class who shall not do commit everytime the DAO will be called.

    Code:
    void deleteObject() {
    new TransactionTemplate(dataSourceTransactionManager).execute(new TransactionCallbackWithoutResult() {
    
                    protected void doInTransactionWithoutResult(TransactionStatus status) {
                        jdbcTemplate.executeUpdate("delete from ....");
                    }
                });
    }
    The JSF-Code calls it once in a request.

    The other class calls the method 1000 times

    How can I do it?

    Thanks,
    Juergen

  • #2
    Hi,

    i would suggest to use declarative transactions in this case (at least move the transaction boundaries into the layer above). Then you will have the control, to call this method from the web layer with one transaction per method call, and group method calls together into one transaction for better throughput inside i.e. batch processing.

    best rgds
    agim

    Comment


    • #3
      Too much work

      Thank you for your reply.
      I will prefer another solution because it is much work to change the transaction management for this single situation.
      Do you have another solution?

      Juergen

      Comment


      • #4
        If you apply a transaction in your calling class, can't the DAO simply participate in this transaction instead? That means you don't need a new one everytime.

        Comment


        • #5
          TransactionTemplate

          Hi,

          I thought that it will exist an solution with a nested TransactionTemplate -- Nested Transaction....

          Juergen

          Comment

          Working...
          X