jamesfredley opened a new issue, #16716:
URL: https://github.com/apache/grails-core/issues/16716

   ## Summary
   
   #16704 makes `load` and `proxy` of a multi-tenant entity run a query, so a 
discriminator filter cannot be bypassed by an identifier load. The gate is 
`persistentEntity.isMultiTenant()`, which is true for any class that implements 
`MultiTenant`, including `DATABASE` and `SCHEMA` mode. The upgrade note says 
those two modes are otherwise unchanged.
   
   ## What goes wrong
   
   `HibernateGormStaticApi.load()` and `proxy()` now call `get(id)` whenever 
the entity class implements `MultiTenant`. `isMultiTenant()` is set from the 
class, not from the tenancy mode (`AbstractPersistentEntity` line 89, 
`ClassUtils.isMultiTenant`).
   
   In `DATABASE` and `SCHEMA` mode there is no discriminator filter to bypass. 
`load(id)` used to return a lazy proxy and throw later if the row was missing. 
It now runs a SELECT immediately and returns null when the row is absent. 
`proxy(id)` does the same, so assigning an association by id hits the database 
and a missing id becomes null instead of a proxy. Hibernate 7 is confirmed. The 
same gate should be checked on the Hibernate 5 static API.
   
   `upgrading80x.adoc` section 87 documents the query behavior for 
discriminator multi-tenancy, then says the `DATABASE` and `SCHEMA` modes are 
otherwise unchanged.
   
   ## Introduced by
   
   - https://github.com/apache/grails-core/pull/16704
   - Merge commit `bde47b01fb2712866da5f04c5a79a3bb19d41816` on `8.0.x`
   - `HibernateGormStaticApi.groovy` lines 314-317 and 329-330
   
   ## Fix
   
   Gate the `get(id)` fallback on discriminator mode. Leave `load` and `proxy` 
lazy in `DATABASE` and `SCHEMA` mode. Add a regression that a missing id in 
those modes still returns a proxy, or document the change and drop the 
"otherwise unchanged" sentence if the eager query is intentional there too.
   


-- 
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