What fields should be used for hashcode()/equals() in Hibernate Entities and when should I override?

Solution Unverified - Updated -

Issue

  • I have to create the method hashCode and equals only for the Java classes that have primary key of the entity or for all the fields of the entity including the List structure?
  • What are the cases that I should implement equals() and hashCode() for hibernate Entities?

Environment

  • JBoss Enterprise Application Platform (EAP)
  • Hibernate

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content