Skip to content

Commit

Permalink
Merge pull request #26325 from qmonmert/sonar310524
Browse files Browse the repository at this point in the history
Sonar: This class overrides 'equals()' and should therefore also override 'hashCode()'
  • Loading branch information
mshima authored May 31, 2024
2 parents aa57047 + 23b6517 commit 8af1f0f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ public class <%= user.dtoClass %> implements Serializable {
Objects.equals(getLogin(), userDTO.getLogin());
}

@Override
public int hashCode() {
return Objects.hash(
getId(),
<%_ for (const { propertyJavaBeanName } of user.fields.filter(field => !field.builtIn && field.relatedByOtherEntity)) { _%>
get<%= field.propertyJavaBeanName %>(),
<%_ } _%>
getLogin()
);
}

// prettier-ignore
@Override
public String toString() {
Expand Down

0 comments on commit 8af1f0f

Please sign in to comment.