Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 355458

Summary: Provide admin user access data from multiple tenants
Product: z_Archived Reporter: Morten <hardhousemouse>
Component: EclipselinkAssignee: Project Inbox <eclipselink.orm-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: guy.pelletier, hardhousemouse, heruan, juliano.castilho, ketanprajapati88, mauromol, raf4352, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=355093
Whiteboard:

Description Morten CLA 2011-08-23 02:35:23 EDT
Build Identifier: 

Multi-tenant entities cannot be queried across tenants for example for doing administration or statistics. 

Possible solutions:
* There should be possible to set a query hint to allow the extra criteria not to be appended at runtime.

* Allow null as tenant-id to disable the functionality

Reproducible: Always

Steps to Reproduce:
1. Mark an entity with @Multitenant and @TenantDiscriminator
2. Create a few entities with different tenants
3. Attempt to query for all of them, for example a count to know the total number of entities to show statistics. Only the count for the current tenant-id is shown.
Comment 1 Morten CLA 2011-08-24 03:03:04 EDT
I other people with the same problems: http://old.nabble.com/Re%3A-Suggestions-for-approaches-to-security-and-queries--p32068946.html

Can you provide any hints on a work-around or where to start looking to create a patch? This issue is a real show-stopper for us, so I would be grateful for any help! Thanks
Comment 2 Guy Pelletier CLA 2011-08-24 08:15:15 EDT
The way to do this currently is to define a new persistence unit with all the same model classes minus the @Multitenant metadata.
Comment 3 Tom Ware CLA 2011-08-24 11:25:30 EDT
Converting to Enhancement.

The enhancement is to provide a means to query without the tenant criteria without duplicating the persistence unit.
Comment 5 Ketan Prajapati CLA 2014-03-24 08:27:09 EDT
I want to use my Multi-Tenant solution without removing/changing annotation or XMl configuration for all entities.

In short, even my entities are annotated with @Multi-Tenant and @TenantDiscriminator annotation, but at all even, I do not set PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT then It should just ignore to add TENANT_ID as an additional criteria instead of throwing below exception.

javax.persistence.PersistenceException: Exception [EclipseLink-6174] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.QueryException
Exception Description: No value was provided for the session property [eclipselink.tenant-id]. This exception is possible when using additional criteria or tenant discriminator columns without specifying the associated contextual property. These properties must be set through Entity Manager, Entity Manager Factory or persistence unit properties. If using native EclipseLink, these properties should be set directly on the session.


For more information, please refer

http://stackoverflow.com/questions/22562770/eclipselink-how-to-turn-off-multi-tenancy-even-if-i-annotate-entity-with-multi/22597988

Ketan Prajapati
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:03:17 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink