I have a entity which inherits from other. On other hand, I\'m using lombok project to reduce boilerplate code, so I put @Data annotation. The annotation
If you want to compare the members of the superclass as well, then use @EqualsAndHashCode(callSuper=true). If, however, you only want to compare fields in the current class you can use @EqualsAndHashCode(callSuper=false) which is the default option.
If you use the Delombok-feature you can see that the difference is that when set to true this line is added to the generated equals method if (!super.equals(o)) return false;. If you have members in the superclass that should be taken into account when comparing two objects, then it has to be set to true to compare correctly.