title: Executing Multiple queries (Insert and Update) in single transaction using Spring JDBC template
body: <p>I am trying to update a row in table A and inserting a row  in table B. This need to be happen in single call. I am using spring JDBC to achieve this.</p>
  
  <p>Sample Code</p>
  
  <pre><code>@Transactional
      public boolean approveTenant(ApproveTenantRequest approveTenantRequest) throws ApplicationException {
          LogUtil.debug(logger, "UserManagementDAO - approveTenant - Start");
          try {
              String updateSQL = "UPDATE tenant_master SET isactive=1, last_modified_by=:lastModifiedBy, last_modified_at= now() "
                      + " WHERE tenant_id=:tenantid and tenant_community_id=:cmntId";
              MapSqlParameterSource parameters = new MapSqlParameterSource();
              parameters.addValue("cmntId", approveTenantRequest.getCommunityId());
              parameters.addValue("tenantid", Integer.parseInt(approveTenantRequest.getTenantId()));
              parameters.addValue("lastModifiedBy", approveTenantRequest.getApprovedBy());
              int updateEffectedRows = jdbcTemplate.update(updateSQL, parameters);
              if(updateEffectedRows==1) {
                  String insertSql= "INSERT INTO users (username,password,isactive,community_id,userrole,created_by)" + 
                          " values (:username,:password,1,:community_id,:userrole,:created_by)";
                  parameters.addValue("username", approveTenantRequest.getEmailId());
                  parameters.addValue("password", approveTenantRequest.getEmailId());
                  parameters.addValue("community_id", approveTenantRequest.getCommunityId());
                  parameters.addValue("userrole", "RESIDENT");
                  parameters.addValue("created_by", approveTenantRequest.getApprovedBy());
                  int insertEffectedRows = jdbcTemplate.update(insertSql, parameters);
                  LogUtil.debug(logger, "UserManagementDAO - approveTenant - End");
                  return insertEffectedRows == 0 ? false : true;
              }else {
                  throw new ApplicationException("Issue in Approving Tenant, Tenant not exist in master data");
              }
          } catch (DataAccessException dataAccessException) {
              logger.error("Data Access Exception " + dataAccessException);
              throw new ApplicationException(dataAccessException.getMessage());
          } catch (Exception e) {
              logger.error("Exception Occured While approving tenant " + e);
              throw new ApplicationException(e.getMessage());
          }
      }
  </code></pre>
  
  <p>Does this code has any flaw? Is this correct way of doing? Can you please suggest.</p>