help please, problems with gorm and MultiTenancy

12 views
Skip to first unread message

José Vilmar Estácio de Souza

unread,
Oct 3, 2017, 11:22:59 AM10/3/17
to grails-de...@googlegroups.com

Hi all.


I'm trying to create a simple application to test the multiTenancy mode since I need to convert an old app to grails 3.3.


In grails-app/conf/application.yml  I've the following declaration:
    gorm:
        multiTenancy:
            mode: DATABASE
            tenantResolverClass: mt.OrganizacaoTenantResolver

I created the following service:

@CurrentTenant
class T1Service {

    def list() {
def l = Plan.findAll()
return l
    }
This works perfectly using the correct tenant id returned by the TenantResolver implementation.

If i change the line 
def l = Plan.findAll()
to
def l = Plan.findAll { id > 0 }

gorm uses the default connection instead of the tenantId returned by the TenantResolver implementation

Am I doing something wrong?
Thanks.

}
José Vilmar, Telefones: 21 2555-2650 e 21 98868-0859,
        Skype: jvilmar

Sergio del Amo Caballero

unread,
Oct 4, 2017, 5:12:15 AM10/4/17
to Grails Dev Discuss
Hello José, 

If you could create a sample project which reproduces the issue, I would suggest creating an issue here:


thanks,
Sergio del Amo

José Vilmar Estácio de Souza

unread,
Oct 4, 2017, 5:53:59 AM10/4/17
to grails-de...@googlegroups.com, Sergio del Amo Caballero
Hello Sergio.

I'll do it.

My test was based in your guideConfigure Datasources dynamically while using DATABASE
Multi-tenancy.  http://guides.grails.org/grails-dynamic-multiple-datasources/guide/index.html?utm_campaign=Groovy%2BCalamari&utm_medium=email&utm_source=Groovy_Calamari98

Thanks for your help and your guide.
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/35d06ea9-14f3-4709-930b-b800149fdf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

José Vilmar Estácio de Souza

unread,
Oct 5, 2017, 6:10:03 AM10/5/17
to grails-de...@googlegroups.com, Sergio del Amo Caballero

Issue created at https://github.com/grails/grails-core/issues/10825.

This is my first issue, I hope that it was done in the correct way.

I hope that this can be fixed soon because I need to convert an app from grails 2.3.11 to grails 3.3.1 and the app needs to access multiple databases.

Thanks.



On 10/04/2017 06:12 AM, Sergio del Amo Caballero wrote:
--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/35d06ea9-14f3-4709-930b-b800149fdf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Sergio del Amo Caballero

unread,
Oct 5, 2017, 6:11:48 AM10/5/17
to vil...@informal.com.br, grails-de...@googlegroups.com
To access multiple-databases you don’t need multi-tenancy features but multi-datasource features.

http://gorm.grails.org/latest/hibernate/manual/index.html#multipleDataSources

José Vilmar Estácio de Souza

unread,
Oct 5, 2017, 6:26:25 AM10/5/17
to Sergio del Amo Caballero, grails-de...@googlegroups.com

The problem is that new clients can be added while the application is active and each client has its own database. A scenario similar to what was shown in the following link:


http://guides.grails.org/grails-dynamic-multiple-datasources/guide/index.html?utm_campaign=Groovy%2BCalamari&utm_medium=email&utm_source=Groovy_Calamari98

Reply all
Reply to author
Forward
0 new messages