• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Where and why to override hashcode() and equals() methods in hibernate domain class?

 
Tusshar Fasate
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am confused about hashcode() and equals() methods.
Why do override them in domain classes?
Please help me out.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tusshar Fasate wrote:Hi,
I am confused about hashcode() and equals() methods.
Why do override them in domain classes?
Please help me out.


Because they are used in Collections, because you might detach them from a Session when you send it to the client, and Equals/Hashcode is used in both cases.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic