Files

21 lines
1.3 KiB
Plaintext

rls_enabled=true. Rows: tenantA=2, tenantB=1
tenantA HQL select count(i) from Invoice i -> 2
tenantA native select count(*) from invoice -> 2
SQL that reached PostgreSQL for the native query:
select set_config('hibernate.tenant_id', ?, true), set_config('hibernate.tenant_id_root', ?, true) [tenantA, false]
select set_config('hibernate.tenant_id', ?, true), set_config('hibernate.tenant_id_root', ?, true) [tenantA, false]
select count(*) from invoice []
tenantA native insert for tenantB -> rejected: PSQLException: ERROR: new row violates row-level security policy for table "invoice"
admin (root) HQL count -> 3 native count -> 3
no tenant set -> rejected: HibernateException: SessionFactory configured for multi-tenancy, but no tenant identifier specified
Outside Hibernate, on plain JDBC connections:
role app, no tenant variable set select count(*) -> 0
role app, after set_config('...','tenantB') select count(*) -> 1
role postgres (superuser) select count(*) -> 3
role app superuser=false bypassrls=false
role postgres superuser=true bypassrls=true
rls_enabled=false. Same data.
tenantA HQL count -> 2 native count -> 3