FINERACT-2653: Fix provisioning category delete failing with mandatory categoryname error#6011
Open
oluexpert99 wants to merge 1 commit into
Open
FINERACT-2653: Fix provisioning category delete failing with mandatory categoryname error#6011oluexpert99 wants to merge 1 commit into
oluexpert99 wants to merge 1 commit into
Conversation
2f31c63 to
542f574
Compare
adamsaghy
reviewed
Jun 22, 2026
| final String sql = "select (CASE WHEN (exists (select 1 from m_loanproduct_provisioning_details lpd where lpd.category_id = ?)) = 1 THEN 'true' ELSE 'false' END)"; | ||
| final String isLoansUsingCharge = this.jdbcTemplate.queryForObject(sql, String.class, new Object[] { categoryID }); | ||
| return Boolean.valueOf(isLoansUsingCharge); | ||
| private boolean isAnyLoanProductsAssociateWithThisProvisioningCategory(final Long categoryId) { |
Contributor
There was a problem hiding this comment.
private boolean isAnyLoanProductsAssociateWithThisProvisioningCategory(final Long categoryId) {
// The category is in use when a provisioning criteria definition references it. Querying the
// m_loanproduct_provisioning_details table was incorrect because category_id belongs to
// m_provisioning_criteria_definition. EXISTS is portable across PostgreSQL, MySQL and MariaDB,
// and avoids counting all matching rows.
final String sql = """
select exists (
select 1
from m_provisioning_criteria_definition
where category_id = ?
)
""";
final Boolean exists = this.jdbcTemplate.queryForObject(sql, Boolean.class, categoryId);
return Boolean.TRUE.equals(exists);
}
Might be even better, no? Can you please look into it?
Contributor
Author
There was a problem hiding this comment.
Thanks @adamsaghy . This has been updated
542f574 to
cd382c6
Compare
Contributor
|
@oluexpert99 Please review the failing checks. |
Contributor
Author
|
Hi @adamsaghy . does not look like a check failure |
…y categoryname error - Load the category by command.entityId() instead of running create-validation on the body-less DELETE. - Drop ProvisioningCategory.fromJson(command), which left the @id null so the in-use check and repository.delete() targeted a transient entity and never removed the row. - Throw ProvisioningCategoryNotFoundException for an unknown id. - Fix the in-use check: it queried the non-existent m_loanproduct_provisioning_details table (failed on every database); query m_provisioning_criteria_definition (where category_id actually lives) with a portable EXISTS that short-circuits at the first match and maps to Boolean across PostgreSQL and MySQL/MariaDB, instead of the MySQL-only "(exists(...)) = 1". - Add ProvisioningCategoryWritePlatformServiceJpaRepositoryImplTest covering delete-success, not-found, and in-use-cannot-delete, asserting create-validation is never invoked on delete. Signed-off-by: oluexpert99 <farooq@techservicehub.io>
cd382c6 to
4857654
Compare
Contributor
Author
|
@adamsaghy . checks passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix provisioning category delete failing with mandatory category name error
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.