|
Hi,
We have an organizational hierarchy, where one unit can have one parent and multiple children. This works fine. The problem is that we would like to be able to change the parents of the organizational units and keep the history of the hierarchy in some way.
The organizational units store different values in a table, and we are aggregating these values for every period. Eg. If we have an organizational unit A with the children B and C, we would summarize/aggregate all the registered values from all of them (A, B and C) in a period P1. If the child C changes parent in the next period P2, we still need to be able to aggregate the registered values for P1 and get the full aggregation of A, B and C (since C was a child of A in P1).
So I'm wondering if anyone have any tips for how to do this in Hibernate? One way might be to make the associations many-to-many, storing some additional data about the period and if the association is active in the link tables, or something like that. Then fetching the parent or collection of children with some kind of where clause in the mapping, checking for active associations. Another way might be to just store some kind of image of the hierarchy every time it changes.
Anyone tried anything like this before?
Thanks,
Kristian
|