Apr 18th, 2011, 11:00 PM
User specific database
I want to use separate database for each user. There will be a common database MainDB which contains the common tables and a mapping table that maps each username with a database name, but user specific data is available in the corresponding database. [tables in all database have same name and structure].
Is this possible in hibernate to select location and name of database at runtime?
Apr 19th, 2011, 02:14 AM
You can use Hibernate Shards.
Apr 19th, 2011, 02:48 AM
I've read the manual of shards [http://docs.jboss.org/hibernate/stab...n/html_single] and what i understood is that shards require all the database configurations to be available when the application starts up.
My requirements are different, what I want is that even if a database is created at runtime it should be hangled properly. Lets say a new user is created with username UserA and a database dbUserA is created for the user, when i login as UserA, I should be access tables in dbUserA database without any code changes. Is it possible using Hibernate Shard or any other hibernate based framework?
Apr 19th, 2011, 03:30 AM
I really don't understand why you try to split your database like this, but then you should rely on your database as some vendor have mechanism to split vertically database.
The other option I can think of, is to manage connection manually which requires a lot of work...
Tags for this Thread