I stucked with a serious problem in architecture of my enterprise application. My current application is a web application using spring framework 3.2+
and jpa 2.0
. Now I need to support multi tenancy in current application.
My requirement is that when a user logged in to the system the data for the user should be served from respective database. In short I need multiple database support which may cause different connection string. So how can I connect to database dynamically?
My another problem is that tenant (particular client of the applications) can register himself on the fly, and on successful registration I need to create a environment containing database creation and initialization etc. for that tenant and on successful creation of environment users of tenants are able to access the application. So problem is how to create environment dynamically, how create EntityManagerFactory
dynamically?
Any suggestions to achieve the multi tenancy are most welcome...