I recently debated with a collegue about how to compare 2 instances of the same java class.
You have an two instances of a complicated object and want to know which attributes differ between those two.
Here is a use case : You have a user profile with lot of fields and the user submits a new profile, you want to know which fields have changed to be able to display something like "successfully changed your birthday, name, street name ..."
So at the moment, the best solution I have is to write a compare method in the class that takes another object and compare every field one by one, then return the list of fields that are differents.
I was wondering if there was any automatic method (from a external library for example) to do that without having to manually specify each attribute.
Btw, if hibernate has a method which could do this to compare local and database object it could do the trick.