I have a group of tables that persist customers' data. At certain points in my application I need to take a snapshot of that data and insert it into an identical but distinct table structure which represents the customer's history trace.
In other words, I have a bunch of tables such as CUSTOMER, APPLICATION, etc. related together and I need the same set of Java objects be able to persist themselves to a different set of tables ie. CUSTOMER_HISTORY, CUSTOMER_APPLICATION etc.
The fields and relations in the _HISTORY tables are identical to the main set of tables so I really don't feel like creating a brand new set of Java classes just to be able to do that. What I need is a clone of the original data in those _HISTORY tables except with all the foreign keys and primary keys regenerated.
Is there a way for Hibernate to dynamically change where its stuff gets persisted or do I need a brand new set of sibling objects mapped to my _HISTORY tables in order to do what I'm trying to do?
All the tables are in the same schema.
Anyone with a suggestion on how to best handle this?
|