JPA: doesn't override equals () and hashCode () in essence?

After reading this article , bending towards not overriding equals () and hashCode () in general.

In the summary of this article regarding no eq / hC in all columns, the only consequence is that I could not perform comparison operations, such as:

  • contains () in the list for individual objects or
  • Compare the same objects from different sessions.

and expect the correct result.

But I still doubt and would like to talk about your experience, be it a bad practice to skip the equals and hashCode values ​​in general and what other consequences that I still don't know about.

Another point of information that bends to the use of collection lists over the set. And my assumption is that I really don't need to redefine hashCode and equal when stored in a list.

+3
source share
3 answers

Read this wonderful article on this topic: Do not let Hibernate steal your identity .

The conclusion of the article is as follows:

, . , . , - Hibernate. , . , .

+3

equals hashCode

. equals hashCode. . , , Object. , 100% . , equals/hashCode, ( ) , . , , , ( ).

. IDE equals/hashCode. IDE -.

+3

, .

. , .

, ; java.

. equals, hashcode. , :

  • .

, , equals/hashcode, . (, ), .

:)

+3

Source: https://habr.com/ru/post/1796241/


All Articles