I have seen a horizontal partitioning of data using Hibernate that hides the SessionFactories, etc in a ConfigUtil class. The idea goes something like this.
The ConfigUtil establishes all SessionFactories and stores them in a map with their associated identifier (ID, class, whatever you choose) as the key. The ConfigUtil then has a call getSessionFactory(identifier) that returns the SessionFactory for the identifier you submit. On 10-10-15 09:43 AM, Li Ying wrote: > We developed a multi-tenant app last year. > > But we didn't separate their data into different DB. > > Instead, we stored all data in one DB, and add > a [tenant_id] column to all tables to distinguish > which tenant it belong. > > I think this is a simpler solution. > > When you need to add new tenant, > you can simply add new records to one DB, > you don't have to create new DB and configure it in your executive > environment. > > And, when you change your DB design, > you don't have to do this in all the DBs. > > > > > 2010/10/15 Eduard Neuwirt <[email protected]>: > >> Hello, >> >> I am looking for an elegant solution for the following situation. >> >> I have a multitenant struts/spring/hibernate application. Every tenant is >> stored in own database within the same RDBMS. All databases has the same >> schema. At the spring layer every tenant is represented as a datasource. >> Because I use the Hibernate I have to create multiple SessionFactories to >> >> How can I provide the correct Seesionfactory to the UserSession in struts. >> Once I have is the tenantId stored in UserSession itself. >> >> Please help >> Eduard >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

