diff --git a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/scope/tenant/TenantScope.java b/annotation-service/annotation/src/main/java/gr/cite/annotation/common/scope/tenant/TenantScope.java index 3c0ac7095..e42eaebcf 100644 --- a/annotation-service/annotation/src/main/java/gr/cite/annotation/common/scope/tenant/TenantScope.java +++ b/annotation-service/annotation/src/main/java/gr/cite/annotation/common/scope/tenant/TenantScope.java @@ -11,8 +11,6 @@ import javax.management.InvalidApplicationException; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -@Component -@RequestScope public class TenantScope { public static final String TenantReplaceParameter = "::TenantCode::"; private final MultitenancyProperties multitenancy; @@ -66,7 +64,14 @@ public class TenantScope { this.tenant.set(tenant); this.tenantCode.set(tenantCode); - if (this.tenant.get() != null && !this.isDefaultTenant()) { + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.TENANT_FILTER); + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER); + if (this.tenant.get() != null || this.isDefaultTenant()) { if(!this.isDefaultTenant()) { entityManager .unwrap(Session.class) @@ -83,7 +88,16 @@ public class TenantScope { public void removeTempTenant(EntityManager entityManager) { this.tenant.set(this.initialTenant.get()); this.tenantCode.set(this.initialTenantCode.get()); - if (this.initialTenant.get() != null && !this.isDefaultTenant()) { + + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.TENANT_FILTER); + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER); + if (this.initialTenant.get() != null || this.isDefaultTenant()) { if(!this.isDefaultTenant()) { entityManager .unwrap(Session.class) diff --git a/notification-service/notification/src/main/java/gr/cite/notification/common/scope/tenant/TenantScope.java b/notification-service/notification/src/main/java/gr/cite/notification/common/scope/tenant/TenantScope.java index 473fa321a..0a27d4cc6 100644 --- a/notification-service/notification/src/main/java/gr/cite/notification/common/scope/tenant/TenantScope.java +++ b/notification-service/notification/src/main/java/gr/cite/notification/common/scope/tenant/TenantScope.java @@ -11,8 +11,6 @@ import javax.management.InvalidApplicationException; import java.util.UUID; import java.util.concurrent.atomic.AtomicReference; -@Component -@RequestScope public class TenantScope { public static final String TenantReplaceParameter = "::TenantCode::"; private final MultitenancyProperties multitenancy; @@ -66,7 +64,14 @@ public class TenantScope { this.tenant.set(tenant); this.tenantCode.set(tenantCode); - if (this.tenant.get() != null && !this.isDefaultTenant()) { + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.TENANT_FILTER); + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER); + if (this.tenant.get() != null || this.isDefaultTenant()) { if(!this.isDefaultTenant()) { entityManager .unwrap(Session.class) @@ -83,7 +88,16 @@ public class TenantScope { public void removeTempTenant(EntityManager entityManager) { this.tenant.set(this.initialTenant.get()); this.tenantCode.set(this.initialTenantCode.get()); - if (this.initialTenant.get() != null && !this.isDefaultTenant()) { + + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.TENANT_FILTER); + + entityManager + .unwrap(Session.class) + .disableFilter(TenantScopedBaseEntity.DEFAULT_TENANT_FILTER); + if (this.initialTenant.get() != null || this.isDefaultTenant()) { if(!this.isDefaultTenant()) { entityManager .unwrap(Session.class)