I'm currently creating a POC and using eclipselink to create subsets of data within a database based on tenants. Works great and allows me to dynamically add new business units on the fly as new tenants. Each unit can access their own dataset based on tenant id.
However I've run across a scenario where I need to implement a concept of an audit user that has read only access to all records within a limited number of tables / entities and their corresponding relationship entities. I'm not sure how exactly to accomplish this.
From what I can understand adding multiple tenant discriminator columns just creates more permutations of the same record (i.e. entity A belongs to company 123 and has a role of manager).
I am using container managed EJB's to manage entity operations ( persist, query / find, merge).
Is there a way to either:
1. Inject a persistencecontext that defines very specific entities within the persistence unit but can query against all tenants (override multi tenancy).
2. Provide multiple tenants to query against?
As a heads up I do not have the capability to generate materialized query tables or any secondary views.
I also intend to audit the heck out of any operation of this sort and lock down this access.