Mass indexing ID loading queries with discriminator multi-tenancy may cross tenant boundaries in some cases

Description

See

I end up with this:

See how the session clearly has a tenant ID, but the query SQL doesn’t include a where clause (where tenantName = ‘mainTenant'). Clearly Hibernate ORM didn’t add the filter it’s supposed to add automatically to every relevant query (see org.hibernate.binder.internal.TenantIdBinder, org.hibernate.internal.SessionImpl#setUpMultitenancy).

TBH this looks more like a Hibernate ORM bug or limitation, but we need to investigate to see if:

  1. Our tests are incomplete; how could this get past CI?

  2. We can work around it by creating our query differently.

  3. We can legitimately report it to Hibernate ORM (maybe it’s a known issue or documented limitation).

Attachments

1

Activity

Show:

Yoann Rodière January 16, 2024 at 8:00 AM

Some update: the problem was actually caused by a bug in Hibernate ORM, , which is going to be solved in Hibernate ORM 6.4.2.

Fixed

Details

Assignee

Reporter

Components

Sprint

Affects versions

Priority

Created December 6, 2023 at 4:17 PM
Updated April 10, 2024 at 8:12 AM
Resolved January 23, 2024 at 8:13 AM