Jmix 1.5 generates equals() and hashCode() methods on entities?

In the documentation of Jmix 2, it clearly states that these methods are generated by Jmix, but in the documentation I cannot find any answer for Jmix 1.

Using the Intellij plugin, when I override one of the methods it says that “Jmix: Methods equals() and hashCode() are added automatically in gradle plugin during entity enhancing. Severe issues may occur in case of manual creation of these methods and mixing them with business logic or another inaccurate definition.”

BUT If you ask to the AI assistant, it says " Jmix, including version 1.5, does not automatically generate equals() and hashCode() methods for entities." so I don’t know what to believe.

Generates.:slight_smile:
In 1.6 (I think that in 1.5) you can see that the entities after assembly have added them:

....
public boolean equals(Object paramObject) {
    return EntityInternals.equals((Entity)this, paramObject);
  }
  
public int hashCode() {
    return EntityInternals.hashCode((Entity)this);
  }

Thank you so much Andrey!

Unfortunately AI assistant is plainly wrong on this topic. We’ll try to teach him better.

1 Like