2
I am tasked with changing an audit implementation in an application in which I work.
The requirement of the audit is to know the history of changes, and execution of certain tasks by a given user. (Initial Status -> Modification 1 -> ... -> Modification N)
The problem is that the current implementation saves the state of the serialized Java object in a field CLOB in the database, and with that we have some problems:
- The application already has more than 3 years in production, and several changes have been made in the course this time, and with that the Java Object was modified, but no maintenance was done in the database for the object unless it has these changes. (For example: a new field added in a class).
- Reverting something to the "Home State", or going back some version in time, whose Java Object no longer reflects running code is no easy task.
- The simple fact of wanting to know the content of the Object under these conditions requires me to retrieve on SVN the version of the class the object was generated in, and this can be difficult, since I don’t know exactly in which commit of code that object was saved.
- It is impossible to view the contents of CLOB performing a simple query in the database.
Discussing with other people, we come to some possible implementations:
- Serialize the Java object in JSON (which would easily discover the code version used by the number of JSON attributes, and it would be humanly possible to read the content in the database).
- Another solution I found would be to use an audit framework that is easily integratable with Spring: Audit4j. This has a customizable layout, and is also humanly readable, and has several functionalities which are very interesting. audit4j
I would like to know in this case what would be the best practices to perform an audit implementation that is: Humanly readable (in database), which has low maintenance, and that the problems between code versions are not so dramatic.
I just discovered this framework (http://javers.org/) I will do some tests, but from the little I read it has already implemented some ideas, and some things I had already done on hand...
– eliocapelati