• 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

 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!