'transactionTemplate.execute - SQLState: 25P02 (current transaction is aborted) with no transaction

When I run jdbcTemplate.query(sql) with no transaction, it works fine,

but if I wrap it with the transactionTemplate.execute( ..

        final var transactionTemplate = new TransactionTemplate(transactionManager);
        transactionTemplate.setIsolationLevel(Isolation.SERIALIZABLE.value());
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);

        transactionTemplate.execute(action -> { 
             ...
             jdbcTemplate.query(sql) // it fails here
             ... 

it Fails with SQLState: 25P02 (current transaction is aborted) with no transaction

The intention is using transactionTemplate to make sure that what is inside execute() to run in mentioned transaction (SERIALIZABLE,PROPAGATION_REQUIRED)

Question: what do I miss? How to make it work.

P.S. I would like to avoid @Transnational annotation.

Progress v is: PostgreSQL 12.5

what I did try is:

  • rollback in progress sql console. yet, there is not pending transaction to roll back.
  • TODO: ..


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source