adamsaghy commented on code in PR #6011:
URL: https://github.com/apache/fineract/pull/6011#discussion_r3450937660
##########
fineract-provider/src/main/java/org/apache/fineract/organisation/provisioning/service/ProvisioningCategoryWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -107,10 +108,14 @@ public CommandProcessingResult
updateProvisioningCategory(final Long categoryId,
}
}
- private boolean
isAnyLoanProductsAssociateWithThisProvisioningCategory(final Long categoryID) {
- 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) {
Review 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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]