MS-241/Fix infinite recursion and unsafe Lombok usage in Order domain entities
Context
Several JPA entities in the Order domain were using Lombok @Data and default
@ToString generation while having bidirectional relationships.
This caused infinite recursion issues (StackOverflowError) during logging
and exposed unsafe equals() / hashCode() implementations.
What was done
- Removed Lombok
@Datafrom JPA entities - Added explicit
@Getter,@Setter,@ToString(exclude = ...) - Restricted
equals()andhashCode()to primary keys only using@EqualsAndHashCode(onlyExplicitlyIncluded = true) - Excluded bidirectional relationships from
toString() - Applied the same safe pattern consistently across all Order-related entities
Why
- Prevent infinite recursion in
toString()caused by bidirectional mappings - Ensure Hibernate-safe
equals()andhashCode()implementations - Avoid StackOverflowError during logging or serialization
- Improve long-term maintainability and consistency of the domain model
Impact
- No database schema changes
- No business logic changes
- Improved runtime stability and logging safety
Notes
This change aligns the Order domain entities with recommended Hibernate + Lombok best practices.
Closes MS-241