This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Policies are jOOQ's primary way to implement client side row level security by transforming DML statements such that certain rows will become invisible to clients running jOOQ queries. A popular example use-case is row based multi-tenancy, e.g. by specifying a condition on a
TENANT_ID column on all tables.
For example, a
Configuration may declare a
org.jooq.Policy on a
CUSTOMER table to filter out
CUSTOMER.TENANT_ID = 42. Users write queries like:
create.select(CUSTOMER.ID, CUSTOMER.NAME) .from(CUSTOMER) .fetch();
But with the policy in place, jooq will render this query instead:
SELECT CUSTOMER.ID, CUSTOMER.NAME FROM CUSTOMER WHERE CUSTOMER.TENANT_ID = 42
Not just queries but all DML statements are affected. It is easy to see how this also applies to UPDATE statements or DELETE statements, which have a
WHERE clause, but it also applies to INSERT statements.
The following sections explain the feature more in detail.