I am currently working on a project where we will be using one database, but with multiple schemas, one per user. The schemas will be identical except for the schema name. In essence, we're keeping our users seperated by using multiple scemas. For example, userA will belong to userA_schema and user B will belong to userB_schema. All schemas will be identical internally (i.e. same table names) so the hibernate classes will not change.
We're currently using Spring with Hibernate as our DAL. I'm just trying to figure out how to allow a user to connect at login to their specific schema. I would not think that it would be possible to get this information from a configuration file, since we won't know which user is connecting until they actually log in. We're also using connection pooling, so that adds a bit of complexity to the problem as well.
My original thought was to find a way to dynamically update the database connection string to allow us to connect to the correct schema, but I haven't seen any documentation that would lead me believe this is feasable. I was also thinking that perhaps I could pass an updated Configuration to the updateSchema method, but this seems to be more related to an update in the table structure rather then a change in the actual schema.
Has anyone else out there setup hibernate in a similar manner? Could you please let me know approximately how you accomplished this? I'm currently at an impasse and I just need a nudge to get me going in the right direction. Any help would be greatly appreciated, thank you!
Michael J
|