This question is about system design with Hibernate (or to say ORM, generally).
Applications often need to keep the change history of business objects. Take an issue-traking system for example. In an issue-tracking system, each step of the issue-processing should be recorded, e.g., when the issue was to set to "acknowledged" status by whom, when the issue was set to "assigned" status by whom and so on...
A well-accepted solution to this on database level is to use two tables in the database:
-One table holds the basic properties of the business object which are supposed to be not changeable, e.g., business IDs etc.(let's call this table basic property table). The primary key is business object ID (an artificial key)
-The other table holds other properties which may be changed often (let's call it extended property table). It has a joint primary key property-id and has the business object id as foreign key.
When properties in "basic property table" are changed, the corresponding record is UPDATED. When properties in "extended property table" are changed, a new record is INSERTED in to the extended property table with a timestamp.
And sometimes, more than one "extended property table" is needed...
The question is: how to design the mapping schema for this kind of requirements?
|