Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Multi-tenancy using shared tables

Hi Theo,

Likely getting that exception if you are setting the property outside of a begin transaction call. Ensure you set the properties after a begin transaction.

You could look to include your tenant properties in your persistence unit definition in the persistence.xml. Then you don't need to pass it to the EM.

Cheers,
Guy

On 07/08/2011 3:53 PM, Theodor Richard wrote:
Hello Guy,

I tried setting the tenant-id at runtime and it works. I'm using EclipseLink in a container-managed environment, i.e., the EntityManager is injected via @PersistenceContext.

I still have the following question: Is there a way to bind the tenant-id to the HttpSession session. I'm frequently getting the following error: No value was provided for the session property [eclipselink.tenant-id].

Currently, I'm setting the tenant-id for every method call to the entity manager, which is rather tedious. Is there a more elegant way?

Thanks,
Theo



On Wed, Jul 27, 2011 at 11:35 PM, Theodor Richard <theodor.richard@xxxxxxxxxxxxxx> wrote:
Hello Guy,

Thanks for your answer. Will try it out and provide feedback. 

Regarding @Unique: it's an JPA annotation that enforces a uniqueness constraint on a database column. And my question was referring to whether this can be used in a multi-tenant environment, i.e. Enforcing uniqueness only within a tenant. 

Regards,
Theo 



On 25.07.2011, at 14:25, Guy Pelletier <guy.pelletier@xxxxxxxxxx> wrote:

Hi Theo,

Yes, EclipseLink's multitenant supports adding and removing tenants at runtime. You are not restricted by the persistence.xml file. Below are a few links that describe our support and usage further. In a nutshell you decorate your multitenant entities with @Multitenant and @TenantDiscriminatorColumns (optional) and can provide tenant id's at the Persistence unit, entity manager factor or entity manager level based on your requirements/needs.

http://wiki.eclipse.org/EclipseLink/Examples/JPA/Multitenant#Persistence_Usage_for_Multiple_Tenants

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Single-Table_Multi-Tenancy

As for @Unique, I'm not aware of this annotation and its usage in EclipseLink's multitenant solution. Where did you see this used?

Cheers,
Guy


On 23/07/2011 11:21 AM, Theodor Richard wrote:
Hi,

I want to convert my current Java EE 6 app to support multi-tenancy. At first, I was gonna do it "manually" by adding a tenant-id into every entity and include it in the every query. But then, I came across EclipseLink's support for multi-tenancy. 

My question: I want to be able to add/remove tenants at runtime. I don't need any tenant-specific customization. Does EclipseLink support this? And how does @Unique behave? Is it restricted to one tenant or does it apply across all tenants? I watched the screencast and read the wiki about Multi-tenancy. It looks like you can only add tenants at deployment time (by changing the persistence XML file)

Thanks,
Theo


_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top