We have tables where historical data are stored together with up-to-date data. If data are historical they have column ST set to 1, if they are up-do-date they are set to 0. Primary key consists of columns DV and PM. DV is unique id of a row in a table and PM is unique id of an entity. Only one row with the same PM has ST=0. If the row is updated, then trigger updates current row by setting ST to 1, and inserts new row to table with the same PM and new DV. This new row is now the current row. Example:
1. The first row is inserted: DV=1, PM=1, ST=0, DATA='AAA'
2. The second row is inserted: DV=2, PM=2, ST=0, DATA='BBB'
3. The first row is updated - we have then 2 rows with PM=1:
DV=1, PM=1, ST=1, DATA='AAA'
DV=3, PM=1, ST=0, DATA='AAB'
The problem is: is it possible to map such datatable in Hibernate? If answer is yes, then how it should be done?
|