Class TenantPredicate

java.lang.Object
dev.dokimos.server.tenant.TenantPredicate

public final class TenantPredicate extends Object
Builds the SQL/JPQL tenant predicate for a TenantScope against a tenant_id path.

The rule is uniform across every scoped entity:

  • unrestricted: no predicate (always true), so every row is visible.
  • scoped(tenantId) with a non-null tenant: tenant_id = :tenantId OR tenant_id IS NULL (own rows plus shared rows).
  • scoped(null) (anonymous): tenant_id IS NULL (shared rows only).
  • Method Summary

    Modifier and Type
    Method
    Description
    static jakarta.persistence.criteria.Predicate
    forScope(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Path<String> tenantIdPath, TenantScope scope)
    Builds the criteria predicate for the scope over the given tenant_id path.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • forScope

      public static jakarta.persistence.criteria.Predicate forScope(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Path<String> tenantIdPath, TenantScope scope)
      Builds the criteria predicate for the scope over the given tenant_id path.
      Parameters:
      cb - the criteria builder
      tenantIdPath - the path to the entity's tenant_id attribute
      scope - the tenant scope to enforce
      Returns:
      the predicate to AND into the query's restriction