Support ORM's discriminator-based multi-tenancy (esp. in the outbox-polling module)

Description

See https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/discriminator-based.20multitenancy/near/264282502

I guess at some point we'll need to identify the tenancy strategy if we mean to support discriminator-based multi-tenancy. We'll need to add a tenantId property to our custom entities (outboxevent, agent) and map them when using discriminator-based multi-tenancy. But that can wait

Activity

Show:

Yoann Rodière May 9, 2023 at 1:09 PM

So it would seem we would be able to add a tenantId field to OutboxEvent, but only map it in org.hibernate.search.mapper.orm.coordination.outboxpolling.event.impl.OutboxPollingOutboxEventAdditionalJaxbMappingProducer#produceMappings if the user is relying on discriminator-based multitenancy, which can be detected in that method through buildingContext.getMetadataCollector().getFilterDefinition(TenantIdBinder.FILTER_NAME) != null.

This will, of course, only work with Hibernate ORM 6.

Yoann Rodière April 21, 2022 at 5:57 AM

Related: https://hibernate.zulipchat.com/#narrow/stream/132094-hibernate-orm-dev/topic/MultiTenancyStrategy

Seems you have to run factory.getDefinedFilterNames().contains( TenantIdBinder.FILTER_NAME ) or metadata.getFilterDefinitions().containsKey( TenantIdBinder.FILTER_NAME ) to detect whether discriminator-based multi-tenancy is enabled. However, from what I can see, it could be enabled on some entities and not on others...

Fixed

Details

Assignee

Reporter

Sprint

Fix versions

Priority

Created December 9, 2021 at 10:45 AM
Updated February 26, 2024 at 1:14 PM
Resolved September 20, 2023 at 9:49 AM