hi all,
In every system, we usually have to create history data and restore from history data.
History data is not just a single entity, but a graph of entities. For example, order -> order details -> line item...
It cost much if we design the same table structure for history data exactly same as main data, for example: orderHistory -> order detailHistory -> line item History...
It cost much more for coding to copy data between main ⇔ history data(id value of main entity and history entity is different).
My solution is:
①
using replicate function of hibernate 3 to transform main data to xml, serialize to history DB.
②
Each time restoring data from history ⇒ main,
load xml data from history DB,
deserialize to entity in session
③
save entity back to main table
Advantage:
cost of design history table =0
code for copy history⇔main = 0
I do not implement yet, but my questions is how to restrict only a part, not all data graph is serialized to xml?
you have any good ideas?
|