Results 1 to 3 of 3

Thread: Open new transaction in @AfterJob event?

  1. #1
    Join Date
    Oct 2012
    Location
    Madrid
    Posts
    20

    Default Open new transaction in @AfterJob event?

    Hi,

    Is it possible to open a new transaction in @AfterStep or @AfterJob event?

    I am seeing that when I try to execute a SQL query the current transaction is closed.




    Thanks,

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    There's nothing stopping you from wrapping those calls in your own transactions. However, there is nothing within the framework that provides those methods to be transactional.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3
    Join Date
    Oct 2012
    Location
    Madrid
    Posts
    20

    Default

    Finally, I solved this problem by opening manually the transaction:

    TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
    totImp = transactionTemplate.execute(new TransactionCallback<BigDecimal>() {

    @Override
    public BigDecimal doInTransaction(TransactionStatus status) {
    (some code....)
    }
    });


    Any better idea?


    Thanks,

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •