在使用ORM时跟踪对db字段的更改 [英] Tracking changes to db fields while using ORM
问题描述
我想跟踪对特定表格中的每个列所做的更改。我想到将更改存储在另一个表与以下列: id,字段和数据
其中字段
值)是目标表中已更改的列, data
是该字段的新值。
I want to track the changes made to every column in a particular table. I thought of storing the changes in another table with the following columns: id, field, and data
where field
(string value) is the column in the target table that has been altered and data
is the new value of that field.
当返回数据集时,我想到从目标表中检索原始数据和从表跟踪更改的值更改,然后使用java的反射功能设置将字段的值更改为最新更改的值。
When returning the data set, I thought of retrieving the original data from the target table and the changed values from the table tracking changes, then using java's reflection capabilities to set the changed fields' values to the newest changed value.
根据上述,我有以下问题:
Based on the above I have the following questions:
- 说得通?
- 我使用JPA 2来处理ORM,是否有任何ORM功能可以帮助实现最终目标?
感谢
推荐答案
检查Hibernate envers Eclipselink实体审计的历史会话..
JPA 2.0规范没有与实体审计相关的任何内容。
Check Hibernate envers and Eclipselink historical session for entity auditing.. JPA 2.0 spec does not have anything related to entity auditing..
这篇关于在使用ORM时跟踪对db字段的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!