Skip to content

FINERACT-2421: Add equals() and hashCode() to LoanTransaction#5855

Open
Harshdhall01 wants to merge 1 commit into
apache:developfrom
Harshdhall01:fix/loan-transaction-equals-hashcode
Open

FINERACT-2421: Add equals() and hashCode() to LoanTransaction#5855
Harshdhall01 wants to merge 1 commit into
apache:developfrom
Harshdhall01:fix/loan-transaction-equals-hashcode

Conversation

@Harshdhall01
Copy link
Copy Markdown

Description

LoanTransaction was missing equals() and hashCode() implementations,
flagged by a long-standing TODO comment in the code:

// TODO missing hashCode(), equals(Object obj), but probably OK as long as
// this is never stored in a Collection.

The parent class AbstractPersistableCustom intentionally omits these methods
(documented in its own Javadoc). Added id-based implementations consistent with
the pattern already used in LoanDisbursementDetails, ensuring correct behavior
if LoanTransaction is ever used in hash-based collections.

Changes

  • Removed stale TODO comment
  • Added equals() based on entity id with null-safety for unsaved entities
  • Added hashCode() based on entity id
  • Added missing java.util.Objects import

Note: JIRA ticket will be linked once Apache JIRA account approval is received.


I am exploring this codebase as part of my DMP 2026 (C4GT) application for the
"Dynamic Pricing of Micro-loans Using Reinforcement Learning" project under
openMF/Mifos. The loan module is directly relevant as it contains the core
transaction logic that my RL environment will model for dynamic pricing decisions.

Checklist

  • Write the commit message as per our guidelines
  • Acknowledge that we will not review PRs that are not passing the build
  • Create/update unit or integration tests for verifying the changes made
  • Follow our coding conventions
  • Add required Swagger annotation and update API documentation
  • This PR must not be a "code dump"

@Harshdhall01 Harshdhall01 force-pushed the fix/loan-transaction-equals-hashcode branch from 638fc79 to 78ae5e4 Compare May 18, 2026 14:31
@adamsaghy
Copy link
Copy Markdown
Contributor

@Harshdhall01 Please use FINERACT-2421 for this.

@Harshdhall01 Harshdhall01 force-pushed the fix/loan-transaction-equals-hashcode branch from 78ae5e4 to 771c404 Compare May 19, 2026 11:46
@Harshdhall01 Harshdhall01 changed the title FINERACT-xxxx: Add equals() and hashCode() to LoanTransaction FINERACT-2421: Add equals() and hashCode() to LoanTransaction May 19, 2026
@Harshdhall01
Copy link
Copy Markdown
Author

Thank you @adamsaghy! Sir Updated the commit and PR title to FINERACT-2421.

@Harshdhall01
Copy link
Copy Markdown
Author

The build failure in fineract-progressive-loan is a pre-existing
ReferenceEquality issue in AdvancedPaymentScheduleTransactionProcessor.java
(lines 1267, 1358) that uses == instead of .equals() for LoanTransaction
comparison. This is unrelated to my change — the errorprone check flags
reference equality regardless of whether equals() is implemented.

@adamsaghy
Copy link
Copy Markdown
Contributor

The build failure in fineract-progressive-loan is a pre-existing ReferenceEquality issue in AdvancedPaymentScheduleTransactionProcessor.java (lines 1267, 1358) that uses == instead of .equals() for LoanTransaction comparison. This is unrelated to my change — the errorprone check flags reference equality regardless of whether equals() is implemented.

It fails because now there is a value equality method available and it tries to enforce it now :)

You should fix these issues by modifying to use from now on the equals method

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.

2 participants