Available in versions: Dev (3.20) | Latest (3.19)

Policies

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.

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo