Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

FINERACT-3259: Migrate loan COB partition query to QueryDSL (SQL 067) - #7197

Open
SamarthPD-21 wants to merge 1 commit into
apache:developfrom
SamarthPD-21:FINERACT-3259-querydsl-loan-cob-partitions
Open

SamarthPD-21 wants to merge 1 commit into
apache:developfrom
SamarthPD-21:FINERACT-3259-querydsl-loan-cob-partitions

Conversation

@SamarthPD-21

Copy link
Copy Markdown
Contributor

Description

FINERACT-3259: replaces the native SQL in RetrieveAllNonClosedIdServiceImpl#retrieveLoanCOBPartitions with QueryDSL (SQL 067 of FINERACT-2022).

  • Same shape as the native query: row_number() over (order by id) in a derived table, floor((n - 1) / pageSize) as the page, then min/max/count grouped and ordered by page. The catch-up flag still only changes the last_closed_business_date filter.
  • The status IDs now come from the existing NON_CLOSED_LOAN_STATUSES list rather than a hard-coded 100, 200, 300, 303, 304. The values are the same.
  • The service takes SQLQueryFactory instead of NamedParameterJdbcTemplate, which only this query used. RetrieveLoanIdConfiguration is updated to match.
  • QueryDSL needs a transaction. LoanCOBPartitioner doesn't open one, but the class is already @Transactional(readOnly = true) and is created through an @Bean, so the call runs in a read-only transaction.

Testing

  • RetrieveAllNonClosedLoanIdServiceImplTest now runs the query through a real SQLQueryFactory on a mocked connection. It checks the generated SQL for PostgreSQL and MySQL, the bound parameters, the catch-up variant and the row mapping.
  • New RetrieveLoanCOBPartitionsDatabaseTest (Testcontainers, QuerydslDatabaseTest) inserts 15 loans across included and excluded statuses, the COB date, other dates and null dates. It runs the old native SQL and the new query against them for partition sizes 1, 2, 3, 4 and 100, with and without catch-up, and checks that the results are equal. It passed on PostgreSQL and on MySQL 8 (-PtestDatabaseEngine=mysql). I didn't run it on MariaDB. fineract-loan gets testFixtures(project(':fineract-qeract-cob already has.
  • All org.apache.fineract.cob.loan tests pass locally (62), and the Error Prone compile is clean.

Checklist

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Write the commit message as per our
    guidelines
  • Acknowledge that we will not review PRs that are not passing the build ("green") - it is
    your responsibility to get a propo primarily the project'smaintainers.
  • Create/update [unit or integt.apache.org/docs/current/#_testing) for verifying the changes made.
  • Follow our codingconventions.
  • Add required Swagger annotation atfineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
  • This PR must not be a "codedump". Large changes can be made in a branch, with assideveloper mailinglist](https://fineract.apache.org/#contribute).
  • If merging this PR resolves t issue as resolved and set "FixVersion/s" appropriately.
  • I followed the AIPolicy.

Your assigned reviewer(s) will follow our guidelines for code reviews.

Signed-off-by: SamarthPD-21 <samarthpd21@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant