Are there any good patterns and/or support in Hibernate-JPA for archived/auditable objects?
For example:
class Boss {
Departement dep;
String name;
Date beginDate;
Date endDate;
}
class Employee {
Boss boss;
}
Bosses come and go, so every so often the current bosses endDate becomes now() and a new Boss is created (for the same departement) with a beginDate of now. This means:
- 90% of the queries on bosses need to have a requirement
WHERE beginDate < now() < endDATE
- an update of boss is actually:
-- create new record with old boss details, but endDate = now()
-- update the original old boss record with new boss details, but beginDate = now()
-- this way all Employee's don't need to switch boss every time the old one gets replaced
- a delete becomes endDate = now()
Is this pattern described somewhere (docs, article, ...? What is the correct term for it (archived, auditable, ...)?
Is there any out-of-the-box support for it in hibernate-JPA?
_________________ http://www.ohloh.net/accounts/ge0ffrey
|