Skip to content

MS-241/Fix infinite recursion and unsafe Lombok usage in Order domain entities

salaheddine zidani a demandé de fusionner feature/MS-241 vers develop

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 @Data from JPA entities
  • Added explicit @Getter, @Setter, @ToString(exclude = ...)
  • Restricted equals() and hashCode() 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() and hashCode() 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

Modification effectuée par salaheddine zidani

Rapports de requête de fusion