0
votes

I have to implement Multi-Tenant Web application having following requirements

  1. Single Table Multi-Tenancy : All tenant's data for particular entity will be stored in a single table with TENANT_DISCRIMINATOR (TENANT_ID) as a column in each table.

  2. Some tables for example Master Countries, Masters... , I want it to be common for all tenants i.e In those table, there will not be a column like TENANT_DISCRIMINATOR (TENANT_ID) and still I want to access it seamlessly.

  3. On request or maintenance reason, I want to move data of Tenant which is already a part of Single Table Multi-Tenancy to a separate database schema and a vice-a-versa by some admin configuration and my web app, on next request should be able to communicate with that updated schema/datasource.

Right now for single table for all tenants. I have used

org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean 

and plugged a

org.springframework.jdbc.datasource.DriverManagerDataSource

into that. I want to have flexibility over here which can read some configuration and help me to decide the same table/data-source or some different data-source.

First two points, I am able to fulfill with EclipseLink framework.

My questions are

  1. Is it possible to implement point 3 using EclipseLink?

  2. Can hibernate 3+ or 4+ help me to implement these ?

Any help will be a appreciated.

1
You will need to outline #3 in more detail, as moving data to another table and having users seemlessly access it is a difficult proposition. What effect do you expect on users currently accessing the old table/application? - Chris

1 Answers

1
votes

Eclipselink does have a remote command that forces the metadata to be refreshed on running factories such that the next EntityManager obtained will use the new metadata. This might allow you to use customizers and/or a metadata repository to make changes to your tenant structure with an admin client and then push those changes to your running application. See http://wiki.eclipse.org/EclipseLink/DesignDocs/368490 and https://wiki.eclipse.org/EclipseLink/Examples/JPA/CacheCoordination