Reputation: 3322
I have to implement Multi-Tenant Web application having following requirements
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.
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.
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
Is it possible to implement point 3 using EclipseLink?
Can hibernate 3+ or 4+ help me to implement these ?
Any help will be a appreciated.
Upvotes: 0
Views: 596
Reputation: 21165
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
Upvotes: 1