gsartori commented on issue #16801: URL: https://github.com/apache/grails-core/issues/16801#issuecomment-6528019769
Also, from the big digital brain: > `@CurrentTenant` and `@Transactional` are being used together to apply the current tenant and run the method in a transaction. They address separate concerns, so the problem does not appear to be a conflict between the annotations. > > The issue seems to be in the transaction manager lookup generated by GORM’s `@Transactional` transform. It calls `CurrentTenantHolder.get()` without specifying a datastore. However, the holder supports a different tenant being bound for each datastore on the same thread. When those tenant IDs differ, the unscoped lookup is ambiguous and throws a `TenantException`. > > A workaround is to override `getTransactionManager()` and use `CurrentTenantHolder.get(targetDatastore)` to resolve the tenant for the service’s datastore, then look up the corresponding transaction manager. > > Ideally, the transform would resolve the current tenant in the context of the target datastore, rather than calling the unscoped `CurrentTenantHolder.get()`. This would let services use `@CurrentTenant` and `@Transactional` together without a custom transaction manager getter. -- 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]
