Programming is about thinking, NOT coding
In either instance you have one application with one database.
Programming is about thinking, NOT coding
Usually the requirement is in a hosted environment, your company is hosting an application for multiple clients. Each client has several users.
Bill Gorder wrote:Jayesh,
Thanks for posting that I was not even aware of multi-tenancy support in Hibernate 4. I still think a database per user is a bad idea ( I don't know how many users we are talking about) but that is my opinion.
I think what you described in the thread already exist in Spring. See AbstractRoutingDataSource.
Programming is about thinking, NOT coding
As for AbstractDataSourceRouting in spring, I tried to implement this in my application then I will have to change the whole structure. We were using JNDI for the datasource until one day the requirement was changed to having multiple databases for the application.
Running multiple instances of the application can be a solution. Can you suggest something on this, that would be of great help!!!
I think the approach Jayesh suggested may be more suitable for your requirements though.
@Jayesh I looked at the link provided by you. Actually I also did something similar to this.
But I would like to know if this can get chaotic if load increases?
Programming is about thinking, NOT coding
Vishal Shaw wrote:
As for AbstractDataSourceRouting in spring, I tried to implement this in my application then I will have to change the whole structure. We were using JNDI for the datasource until one day the requirement was changed to having multiple databases for the application. Running multiple instances of the application can be a solution. Can you suggest something on this, that would be of great help!!!
@Jayesh I looked at the link provided by you. Actually I also did something similar to this. For every request, I configured a filter that checks if the current datasource is the required one, otherwise reinitialize the entitymanager with the required datasource. But I would like to know if this can get chaotic if load increases?
Programming is about thinking, NOT coding
Jayesh A Lalwani wrote:
my AbstractRoutingDataSource looks up the TL variable and routes to the datasource assosicated with that suffix.
Programming is about thinking, NOT coding
Jayesh A Lalwani wrote:ok when I say "my" AbstractRoutingDataSource, I mean the class that I implemented. I can't post the code on here, but I did find someone who implemented what you need here
Programming is about thinking, NOT coding
Specify the map of target DataSources, with the lookup key as key. The mapped value can either be a corresponding DataSource instance or a data source name String (to be resolved via a DataSourceLookup.
The key can be of arbitrary type; this class implements the generic lookup process only. The concrete key representation will be handled by resolveSpecifiedLookupKey(Object) and determineCurrentLookupKey().
Programming is about thinking, NOT coding
Consider Paul's rocket mass heater. |