Skip to content

Commit

Permalink
Fix problem with tenantId part of Composite identifier (#451) (#479)
Browse files Browse the repository at this point in the history
* Fix problem with tenantId part of Composite identifier

Fixes #450

* add multitenant with composite

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>

Co-authored-by: Sergio del Amo <sergio.delamo@softamo.com>
  • Loading branch information
Puneet Behl and sdelamo committed Jan 12, 2022
1 parent 39f8854 commit 031b5b9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions examples/test-data-service/grails-app/conf/application.yml
@@ -1,3 +1,8 @@
grails:
gorm:
multiTenancy:
mode: DISCRIMINATOR
tenantResolverClass: org.grails.datastore.mapping.multitenancy.web.SessionTenantResolver
---
grails:
profile: rest-api
Expand Down
@@ -0,0 +1,15 @@
package example

import grails.gorm.MultiTenant

// Issue: https://github.com/grails/gorm-hibernate5/issues/450
// Pr: https://github.com/grails/gorm-hibernate5/pull/451
class MultitenantBook implements MultiTenant<MultitenantBook>, Serializable {
String id
String tenantId
String title

static mapping = {
id composite: ['id', 'tenantId']
}
}
Expand Up @@ -1443,7 +1443,7 @@ protected void addMultiTenantFilterIfNecessary(
mappings.addFilterDefinition(new FilterDefinition(
GormProperties.TENANT_IDENTITY,
filterCondition,
Collections.singletonMap(GormProperties.TENANT_IDENTITY, persistentClass.getProperty(tenantId.getName()).getType())
Collections.singletonMap(GormProperties.TENANT_IDENTITY, getProperty(persistentClass, tenantId.getName()).getType())
));
}
}
Expand Down

0 comments on commit 031b5b9

Please sign in to comment.