Package dev.dokimos.server.tenant
Class TenantPredicate
java.lang.Object
dev.dokimos.server.tenant.TenantPredicate
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 TypeMethodDescriptionstatic jakarta.persistence.criteria.PredicateforScope(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Path<String> tenantIdPath, TenantScope scope) Builds the criteria predicate for the scope over the giventenant_idpath.
-
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 giventenant_idpath.- Parameters:
cb- the criteria buildertenantIdPath- the path to the entity'stenant_idattributescope- the tenant scope to enforce- Returns:
- the predicate to AND into the query's restriction
-