Multi-tenant plugin: cross-tenant data visibility

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Multi-tenant plugin: cross-tenant data visibility

Michael Sickler
I am using Grails 1.3.7 with the multi-tenant-core plugin in single-database mode with the spring-security plugin.

How do I get access to all data in the app, regardless of who the tenant is?

Thanks,
Mike Sickler
Reply | Threaded
Open this post in threaded view
|

RE: Multi-tenant plugin: cross-tenant data visibility

Bradley Booth

I don’t believe this is implemented yet, but the feature has been requested.  I believe someone even submitted a patch for this “god mode” feature, but I have been out of the loop for a while.  Scott might be able to comment on this further.

 

Description: https://infusionmedia.s3.amazonaws.com/email/signatures/companywide/0210/employees/th-BRADLEY%20BOOTH.jpg

Small Business Growth Expert
BRADLEY BOOTH
Sr. Software Engineer

480-385-7620
[hidden email]

Description: https://infusionmedia.s3.amazonaws.com/email/signatures/companywide/0210/diver.gif

Description: https://infusionmedia.s3.amazonaws.com/email/signatures/companywide/0210/logo.jpg

Description: https://infusionmedia.s3.amazonaws.com/email/signatures/companywide/0210/icon-blog.jpg

 

 

From: Michael Sickler [mailto:[hidden email]]
Sent: Sunday, March 06, 2011 7:27 AM
To: [hidden email]
Subject: [grails-user] Multi-tenant plugin: cross-tenant data visibility

 

I am using Grails 1.3.7 with the multi-tenant-core plugin in single-database mode with the spring-security plugin.

 

How do I get access to all data in the app, regardless of who the tenant is?

 

Thanks,
Mike Sickler

Reply | Threaded
Open this post in threaded view
|

Re: Multi-tenant plugin: cross-tenant data visibility

scryan
In reply to this post by Michael Sickler
There is a doWithTenant method on the TenantUtils that works for both modes.  In the single database per tenant mode you just need to make sure you call it before you open the transaction.    For example create a Service that does not have transactions turned on .  Then look up a service via the spring context.   Now wrap the calls to that service in the doWithTenant method and it will open a transaction and inject the proper tenant.  We use this for supporting quartz jobs and other non url related actions.   Just remember to flush and clear the Hibernate 1st level cache each time you switch tenants.

I hope this helps.


Scott Ryan
CTO
Denver, Colorado  USA
(303) 263-3044

On Mar 6, 2011, at 7:26 AM, Michael Sickler wrote:

I am using Grails 1.3.7 with the multi-tenant-core plugin in single-database mode with the spring-security plugin.

How do I get access to all data in the app, regardless of who the tenant is?

Thanks,
Mike Sickler

Reply | Threaded
Open this post in threaded view
|

Re: Multi-tenant plugin: cross-tenant data visibility

Michael Sickler
Thanks Scott. I understand that I can use doWithTenant to work on an individual tenant's code. But let's say I wanted to run a report that analyzed sales data across multiple tenants. Can I do that with Hibernate? 

On Sun, Mar 6, 2011 at 3:16 PM, Scott Ryan <[hidden email]> wrote:
There is a doWithTenant method on the TenantUtils that works for both modes.  In the single database per tenant mode you just need to make sure you call it before you open the transaction.    For example create a Service that does not have transactions turned on .  Then look up a service via the spring context.   Now wrap the calls to that service in the doWithTenant method and it will open a transaction and inject the proper tenant.  We use this for supporting quartz jobs and other non url related actions.   Just remember to flush and clear the Hibernate 1st level cache each time you switch tenants.

I hope this helps.


Scott Ryan
CTO
Denver, Colorado  USA
(303) 263-3044

On Mar 6, 2011, at 7:26 AM, Michael Sickler wrote:

I am using Grails 1.3.7 with the multi-tenant-core plugin in single-database mode with the spring-security plugin.

How do I get access to all data in the app, regardless of who the tenant is?

Thanks,
Mike Sickler


Reply | Threaded
Open this post in threaded view
|

Re: Multi-tenant plugin: cross-tenant data visibility

Jean Barmash 1
Michael,

We implemented the Master (previously referred to as God) Mode, which works for single-database use case.  There is a pull request into the main multi-tenant-core request, but I believe there is some refactoring being done for the next versions that's preventing the merge.   The code is in repo below - feel free to use it. 

https://github.com/vk77/grails-multi-tenant-core

Thanks,

Jean


On Mon, Mar 7, 2011 at 8:18 AM, Michael Sickler <[hidden email]> wrote:
Thanks Scott. I understand that I can use doWithTenant to work on an individual tenant's code. But let's say I wanted to run a report that analyzed sales data across multiple tenants. Can I do that with Hibernate? 


On Sun, Mar 6, 2011 at 3:16 PM, Scott Ryan <[hidden email]> wrote:
There is a doWithTenant method on the TenantUtils that works for both modes.  In the single database per tenant mode you just need to make sure you call it before you open the transaction.    For example create a Service that does not have transactions turned on .  Then look up a service via the spring context.   Now wrap the calls to that service in the doWithTenant method and it will open a transaction and inject the proper tenant.  We use this for supporting quartz jobs and other non url related actions.   Just remember to flush and clear the Hibernate 1st level cache each time you switch tenants.

I hope this helps.


Scott Ryan
CTO
Denver, Colorado  USA
<a href="tel:%28303%29%20263-3044" target="_blank">(303) 263-3044

On Mar 6, 2011, at 7:26 AM, Michael Sickler wrote:

I am using Grails 1.3.7 with the multi-tenant-core plugin in single-database mode with the spring-security plugin.

How do I get access to all data in the app, regardless of who the tenant is?

Thanks,
Mike Sickler



Reply | Threaded
Open this post in threaded view
|

Re: Multi-tenant plugin: cross-tenant data visibility

Kimble
In reply to this post by Michael Sickler
Michael Sickler wrote
Thanks Scott. I understand that I can use doWithTenant to work on an
individual tenant's code. But let's say I wanted to run a report that
analyzed sales data across multiple tenants. Can I do that with Hibernate?
You can try opening a stateless Hibernate session, I don't think the query / criteria rewriting applies to stateless sessions.
 - Kim A. Betti
Have a nice day!