Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to compare hierarchy of entities

 
Csaba Szegedi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

Q1. Which is the most effective way comparing hierarchy of entities to make decision on updating them or not ?
Should I write own equal and hasCode methods according the role of the entities or I can rely on JPA ?


Afterword:
Rely on the equals and hashCode is already clear for me. It seems to me everything depends on purpose of the entity (Country, Person etc )

I have collected some fundamental role about them.

if you override equals, you must override hashCode.
hashCode must generate equal values for equal objects.
equals and hashCode must depend on the same set of "significant" fields.

I saw some implementation of equals and hashcode here comes an interesting one e.g.:https://aptframework.dev.java.net/jelly/entityEquals.html

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic