How do compare Java objects and properly audit values on updates

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I have an application server that sends an array of record data to the client in response to a search. Prior to sending the data to the client, my thought is to have the server store the data in a session variable.

When the user selects and then submits a record to edit, the client sends the entire record to the server. It updates the entire the record in the database (in case some other user has committed an update after they have searched).

However, I still need to capture the changes so that I can properly store audit information. I think it s best to capture old and new values based on what the user saw and changed. Therefore, I plan to (deep) compare field by field the record in the session data and the updated record sent by the client. I have two questions:

1) Are there pitfalls/problems with this approach?

2) If not, what is a good Java utility/library for comparing objects?

Thanks in advance for your help.

Answers

You may be better off rejecting the change if another use has changed any field in the record. You can alert the user that the record has change and show them the new data to perform the update again (maybe keep their changed values available to them).

This way if another user changes a field that relates to a field they did not change, you will not be making changed to the records that no longer make sense with each other.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/13867463/how-do-compare-java-objects-and-properly-audit-values-on-updates

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils