Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 43e353e

Browse files
puneetbehlsdelamo
andauthored
Fix problem with tenantId part of Composite identifier (#451)
* Fix problem with tenantId part of Composite identifier Fixes #450 * add multitenant with composite Co-authored-by: Sergio del Amo <[email protected]>
1 parent f59ed9d commit 43e353e

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

examples/grails-data-service/grails-app/conf/application.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
grails:
2+
gorm:
3+
multiTenancy:
4+
mode: DISCRIMINATOR
5+
tenantResolverClass: org.grails.datastore.mapping.multitenancy.web.SessionTenantResolver
16
---
27
grails:
38
profile: rest-api
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package example
2+
3+
import grails.gorm.MultiTenant
4+
5+
// Issue: https://github.com/grails/gorm-hibernate5/issues/450
6+
// Pr: https://github.com/grails/gorm-hibernate5/pull/451
7+
class MultitenantBook implements MultiTenant<MultitenantBook>, Serializable {
8+
String id
9+
String tenantId
10+
String title
11+
12+
static mapping = {
13+
id composite: ['id', 'tenantId']
14+
}
15+
}

grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/cfg/GrailsDomainBinder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ protected void addMultiTenantFilterIfNecessary(
14431443
mappings.addFilterDefinition(new FilterDefinition(
14441444
GormProperties.TENANT_IDENTITY,
14451445
filterCondition,
1446-
Collections.singletonMap(GormProperties.TENANT_IDENTITY, persistentClass.getProperty(tenantId.getName()).getType())
1446+
Collections.singletonMap(GormProperties.TENANT_IDENTITY, getProperty(persistentClass, tenantId.getName()).getType())
14471447
));
14481448
}
14491449
}

0 commit comments

Comments
 (0)