I am trying to implement a MultiTenant application using GORM 6.0.0.RC2. When a domain class that implements MultiTenant is saved via the GORM's save() method, the tenantId property is not set to the current tenantId. It is always null and hence fails validation. However Tenants.currentId() returns the correct tenant id based on the specified tenant resolver class.
Is it the application's responsibility to set the tenantId on an instance of the domain class when it is saved or will GORM take care of it by setting the property appropriately before being saved?
My Domain Person class
class Person implements MultiTenant<Person> {
String id
String tenantId
String name
}
and the code to save an instance of the Person class is
new Person(name: "pmohan").save(failOnError: true)
it always fails with a validation exception indicating tenantId is null. But the tenant resolver according to the configuration below resolves to the right tenantId.
gorm:
multiTenancy:
mode: DISCRIMINATOR
tenantResolverClass: com.MyTenantResolver
Also the Tenants.currentId returns the value as expected. I was expecting the save() method to populate the tenantId property automatically based on MyTenantResolver class.