Problem:
I've a set of huge tables (mapped to hibernate objects) containing a week's data. Once a week is over, I rename the tables by adding some suffix (for eg. MyTable renamed to MyTable_1) & create new tables to continue with the new week.
In some places, I want to access the data from previous week's tables using hibernate.
Solution in my mind:
1. Create a Configuration object with the normal class-to-table mappings.
2. Iterate over all the Table instances & add the suffix to the table name.
3. Create SessionFactory & sessions using this configuration, without affecting the original SessionFactory.
Questions:
1. Is this the best approach? Will I face any problems by following this like caching?
2. If this approach is correct, then I need some easier API to get Table handle from Configuration. Currently I've to iterate through all PersistentClasses, Properties & so on. I noticed that all Table instances are there in Configuration class itself. It will be really helpful, if accessor is provided for this also.
Thanks in advance,
Karthi
Hibernate version:2.1.4
Name and version of the database you are using:MySQL 4.1.3 beta
|