MS-241/fix: Prevent infinite loops in Order entity relationships
Problem
Entity classes in the Order domain had bidirectional relationships without proper exclusions in toString() and equals() methods, causing potential infinite loops and stack overflow errors during:
- Logging operations
- Debugging sessions
- Entity comparisons
Solution
Added @ToString.Exclude and @EqualsAndHashCode.Exclude annotations to all bidirectional relationships:
Modified Entities
- Order: Excluded collections (orderLines, notes, editHistory, orderStatusHistories, refundOrders, giftCards)
- OrderLine: Excluded order parent reference
- Note: Excluded order parent reference
- EditHistory: Excluded order parent reference
- OrderStatusHistory: Excluded order parent reference
- RefundOrder: Excluded refundOrderLines collection and order reference
- RefundOrderLine: Excluded refundOrder and orderLine references
Impact
Testing
-
Verified all entities compile successfully -
Confirmed no impact on existing unit tests -
Validated toString() output is safe and readable -
Checked equals() and hashCode() behavior
Related Issues
Closes MS-241