Quantcast
Channel: Magnus K Karlsson
Viewing all articles
Browse latest Browse all 526

Java 7 - Implement equals() and hashCode() with java.util.Objects

$
0
0

When using JPA you should implement equals() and hashCode() if you

  • Intend to put instances of persistent classes in a Set.
  • Intend to use reattachment of detached instances.

For JDK 7 and above, you can use the new java.util.Objects class to generate the equals and hash code values.

Test code


Viewing all articles
Browse latest Browse all 526

Trending Articles