Hibernate version: 3.0
Using Oracle 10g:
I'm new to Hibernate, and I like what I see so far, but I need some help with an
odd data model.
This data model (inherited, non-negotiable) contains, among other tables, a virtually unbounded number of tables with the exact same structure and slightly different names. For example:
my_data_1
my_data_2
..
my_data_n
all have the exact same structure (in the actual database the names are not sequential, but you get the idea). The theoretical upper limit of n is roughly a billion. I'd like to load, update, save and delete objects for these tables using Hibernate, but I'd obviously rather not create a separate object and mapping file for each table, especially since part of the application creates these tables dynamically. The easiest solution
(imho) would be for me to be able to specify the table name when I perform the load(), save(), update(), etc. operation, but I
know I can't do that.
My alternative approach would be to create a template hbm.xml file and plug in the table name and create a new SessionFactory whenever I want to work with one of these tables. There are some obvious drawbacks to this approach, but I think it would work under very restrictive circumstances.
My question is, is there a better way to do something like this that I've missed in all of the Hibernate docs I've looked through (other than re-working the data model)?