Hello everyone,
We are trying to implement entity versioning / history to a system that wasn't originally designed for it.
We want that each update to a versioned entity results in a new row instead of an update. We also need to retrieve the versioned entities (which are often associated together) at certain points of time. Basically there are Reports which refer to a these entities and the reports need to use the the versions of entities that were valid at the time the report was created.
Currently we are looking at having two database tables for each versioned entity:
ENTITY-table would have the unchanging things, mostly just the entity's id and id's of the associated other entities.
ENTITY_VERSION table would have all the values that can change together with VALID_FROM , VALID_TO values.
Now, is it possible to map the ENTITY POJO so that a) The fields would be composed from both tables b) somehow parameterize it with a date so that the correct row from the ENTITY_VERSION table would be used to populate the fields?
Or is there some more obvious way to achieve this?
(Edit: We use MySQL 5 and the latest GA release of Hibernate)
|