Hibernate version:2.1.7
Name and version of the database you are using:
IBM DB2
I am developing an application for a legacy system where a schema exists for each customer. As new customers are added, new schemas are created to hold their data. I would like to have one class and one mapping file for each unique table, not one for each table in each schema. So, if there is a person table, for instance, in each customer schema then I would like to have one person.hbm.xml mapping, and one Person class. Then, at runtime, I would like to dynamically associate classes with schemas.
It seems that once you've created a SessionFactory, a given class is bound to a given table (within a given schema.) So, I'm guessing that I would have to create a SessionFactory for each customer, and somehow on the configuration object I would need to associate the appropriate schema just prior to building the SessionFactory. But, I'm having a lot of trouble doing this. I tried calling createMappings, then updating the schema on the returned Mappings object, then building the SessionFactory, but no luck. Perhaps I was to do something else with that Mappings object?
If anybody can give me some advice on this I would be very grateful. Also, I saw in another similar post that Hibernate3 might have some functionality for this, but it did not mention what functionality, classes, configurations or whatnot were used, so if anybody could point me in the direction of a specific feature in Hibernate3 that mkes this easier, please do, although my preference for now would be to stick with Hibernate2.x until Hibernate3 is released.
|