protected void addMultiTenantFilterIfNecessary ( HibernatePersistentEntity entity , PersistentClass persistentClass , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { if ( entity . isMultiTenant ( ) ) { TenantId tenantId = entity . getTenantId ( ) ; if ( tenantId != null ) { String filterCondition = getMultiTenantFilterCondition ( sessionFactoryBeanName , entity ) ; persistentClass . addFilter ( GormProperties . TENANT_IDENTITY , filterCondition , true , Collections . emptyMap ( ) , Collections . emptyMap ( ) ) ; mappings . addFilterDefinition ( new FilterDefinition ( GormProperties . TENANT_IDENTITY , filterCondition , Collections . singletonMap ( GormProperties . TENANT_IDENTITY , persistentClass . getProperty ( tenantId . getName ( ) ) . getType ( ) ) ) ) ; } } }
Add a Hibernate filter for multitenancy if the persistent class is multitenant