jdaugherty commented on code in PR #16723:
URL: https://github.com/apache/grails-core/pull/16723#discussion_r4408203662
##########
grails-data-hibernate5/core/src/main/groovy/org/grails/orm/hibernate/AbstractHibernateGormStaticApi.groovy:
##########
@@ -178,9 +179,9 @@ abstract class AbstractHibernateGormStaticApi<D> extends
GormStaticApi<D> {
@Override
D load(Serializable id) {
- if (persistentEntity.isMultiTenant()) {
- // Hibernate's tenant filter does not apply to a load by
identifier, so a multi-tenant entity is loaded
- // through a query, as get(id) does, rather than handed to
whichever tenant asks for the id
+ if (persistentEntity.isMultiTenant() && multiTenancyMode ==
MultiTenancyMode.DISCRIMINATOR) {
+ // Hibernate's discriminator tenant filter does not apply to a
load by identifier, so use a query,
+ // as get(id) does, rather than handing out another tenant's row.
return get(id)
}
Review Comment:
Hibernate 5 does not override `proxy`: core's `GormStaticApi.proxy` calls
`load`, which dispatches to this override, so the gate covers `proxy` there as
well.
##########
grails-data-hibernate7/core/src/main/groovy/org/grails/orm/hibernate/HibernateGormStaticApi.groovy:
##########
@@ -311,9 +312,9 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
@Override
D load(Serializable id) {
- if (persistentEntity.isMultiTenant()) {
- // Hibernate's tenant filter does not apply to a load by
identifier, so a multi-tenant entity is loaded
- // through a query, as get(id) does, rather than handed to
whichever tenant asks for the id
+ if (persistentEntity.isMultiTenant() && multiTenancyMode ==
MultiTenancyMode.DISCRIMINATOR) {
+ // Hibernate's discriminator tenant filter does not apply to a
load by identifier, so use a query,
+ // as get(id) does, rather than handing out another tenant's row.
return get(id)
}
Review Comment:
The DISCRIMINATOR path is already covered:
`PartitionedMultiTenancyFilterSpec` in both Hibernate modules has the feature
`load and proxy return an instance of the current tenant only`, which loads the
current tenant's id and gets `null` for the other tenant's id through both
`load` and `proxy`.
--
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]