In our developing work, there is a requirement which is recording log. The log can be classified into two kinds: action log which includes business meaning and data log which just includes data change.
In our planning, action log and data log are realized separately. A struts2 interceptor is used to record action log and hibernate eventListener is used to record datalog.
Then, a link ID is designed to build relationship between the both logs. In the design, when an action happens, the ID is added into a domain entity. When the entity is inserted or updated in the database, hibernate eventListener will get the ID value and record it with data log. Because the ID value will not be recorded in the database with domain entity, we don't deploy it in hibernate-mapping file.
However, in actual work, we find that hibernate will filter the ID if it isn't deployed in hibernate-mapping file. Deploying the ID in every domain entity will bring weighty labor load to our developing job for the project duration has outdistanced half.
So could you help me to solve the problems like: how can we get the ID in eventListener? If it is hard to realize, how can we get the ID from domain entity with a alternative solution in case that the ID need not be deployed in hibernate-mapping file.
We are eagering for your reply and appreciate your kind help!
|