diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java index bce78bd949c..751e691dd8d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java @@ -1570,8 +1570,10 @@ public CommandProcessingResult modifyApplication(final Long loanId, final JsonCo } else { additionals.update(command); } + String deleteExtraLoans = "delete from m_loan_external_existing_loans where loan_id=?"; + this.jdbcTemplate.update(deleteExtraLoans, existingLoanApplication.getId()); updateExternalLoans(command, additionals); - this.groupLoanAdditionalsRepository.save(additionals); + this.groupLoanAdditionalsRepository.saveAndFlush(additionals); } if (productRelatedDetail.isInterestRecalculationEnabled()) {