Hi all,
I'm working through a redesign of our system that will involve future-effective dating some entities. I am aware of using a filter for effective-date entity queries in general, and also the existence of Hibernate Envers (which I plan to use). But, in the case of a revision of an entity that's supposed to become effective in the future, wouldn't that involve creating a new entity instance, with a new ID? How would I then ensure that this entity, with a new ID, replaces the old entity instance in any collections? See below for the ubiquitous Employee / Department example:
An Employee A, entity ID 1, has a name, with effective from & to values of, let's say 1/1/2011 to 12/31/9999 (infinite). That Employee is a member of a Department entity's employees collection.
I go to set that Employee's name today, 6/21/2011, to change to something else, effective 7/1/2011. So, at least as I understand it, I would create a copy of Employee A, entity ID 2, effective 7/1/2011 to 12/31/9999, and set ID 1's effective end date to 6/30/2011.
Aside from somehow knowing in my Employee DAO that I have to add that new entry, ID 2, to all collections of Employees... How would this be handled?
I guess effective dating filters and Envers are great for handling revisions that occurred in the past, since those revisions would all have the same entity ID value. But what about revisions that are supposed to take effect in the future some time?
Thanks!
|