Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with tenantId part of Composite identifier #451

Merged
merged 2 commits into from Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/grails-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