title: Spring boot @Transactional not rolling back the database inserts
body: <p>Need some help here, I'm not able to understand why my transactions are not getting rolled back in an event of exception.</p>
  <p>I will try to put my code as close to as It is on the project (cannot share on the internet)</p>
  <p>This is my Service</p>
  <pre><code>@Service
  @SL4j
  @Transactional(propagation = propagation.SUPPORTS, readOnly=true)
  public class PublicationServiceImpl implements PublicationService{
      @Autowired 
      private PartnerRepo partnerRepo;
                  
      @Autowired
      private FlowRepo flowRepo;
  
      @Autowired
      private PubRepo pubRepo;
                  
      @Override
      @Transactional(propagation = propagation.REQUIRED, rollbackFor=Exception.class)
      public int save(Request request) {
      try{
                     int  pk_id_partner = partnerRepo.save(request);
                     int  pk_id_flow = flowRepo.save(request);
          
                     String publicationCode = generatePubCode(request);
                     int publicationCode= pubRepo.save(pk_id_partner, pk_id_flow, request);
          }
          catch(Exception e){
          log.error(&quot;Exception in saving&quot;);
      }
      return 0;
      }
  }
  </code></pre>
  <p>This is my Repository (example of 1 , all 3 repos follow same coding standards)</p>
  <pre><code>@Repository
  @Slf4j
  public class PartnerRepo implemets PartnerRepo{
      @Autowired
      private NamedParamaterJDBCTemplate namedParamaterJDBCTemplate;
      //String Declarations .....
  
      private MapSqlParameterSource sqlParameterSource;
  
      @Override
      public int save(Request request){
          sqlParamatersSource = new MapSqlParameterSource();
          //sqlParamatersSource.addValue(.....)
          //sqlParamatersSource.addValue(.....)
          //sqlParamatersSource.addValue(.....)
  
          return executeQuery();
      }
  
      private int executeQuery(){
          try{
              keyHolder = new GenerateKeyHolder();
              namedParamaterJDBCTemplate.update(getInsertQuery(), sqlParamaterSource , kekHolder, new String[]{&quot;pk_id&quot;})
              return keyHolder.getKey().intValue();
          }catch(Exception e){
              log.error(&quot;Exception while saving&quot;);
              return 0;
          }
      }
  }
  </code></pre>
  <p>So the problem is , Consider there is an exception in the method <code>generatePubCode(request);</code> , ideally since I have used <code>@Transactional</code> at class level and method level , The previous 2 repo transactions () should be rolled back right? However it isn't happening, Even After the code is finished execution I can see the records in DB (Postgres DB v10).</p>
  <p>Please help figure out this issue , Am I doing something fundamentally wrong ?</p>
  <p>Please do let me know in case you need further information that might help here!</p>
  <p>P.S: I have tried all permutations of <code>@Transactional</code> , nothing works : ONLY having this in the catch block works!  <code>TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();</code>
  I wonder If its the right approach for a springBoot project</p>
  <p>Thanks in advance for the help!</p>
  <p>Edit: as per suggestion made the <code>PublicationServiceSaverImpl.save()</code> public</p>
  <p>Best reagards,
  Bhargav.</p>