matrei commented on PR #16827:
URL: https://github.com/apache/grails-core/pull/16827#issuecomment-6612870333

   Thanks! All three hold, and I've addressed them:
   
   1. `findCurrentTenantTransactionManager(datastore)` now takes the connection 
of the tenant from the datastore it is bound for, through 
`getDatastoreForConnection`, when that datastore is a 
`MultipleConnectionSourceCapableDatastore`. When the datastore has no 
connection of that name, it returns `null`, rather than another datastore's 
connection of that name. Other datastores still go through the registry, as 
before.
   
   2. For `@Transactional(datastore = X)`, the generated getter now calls a new 
`GormRegistry.findCurrentTenantTransactionManagerByType(X)`, which looks up the 
tenant bound for the datastore of that type. Unlike `findDatastoreByType`, it 
does not throw when no datastore of the type is configured, but returns `null`, 
so the getter falls back as it does now. Together with 1, the class now gets 
the transaction manager of `X`'s own connection `one`. Before this PR, the 
unscoped lookup took whichever connection named `one` the registry held.
   
      One detail: `Tenants.withId(Class, ...)` takes a domain class, not a 
datastore type. The tenant is bound for such a datastore with 
`Tenants.withId(datastore, 'one')`, `Tenants.withCurrent(X)` or 
`@CurrentTenant(datastore = X)`, so the case holds as you describe it.
   
   3. The generated data service getter now calls `getDatastore()` once and 
keeps the result in a local variable.
   
   `GormRegistrySpec` has two new features and `TransactionalTransformSpec` 
one. Each fails with its change reverted.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to