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


Applies to ❌ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

A org.jooq.Policy is a configuration consisting of a:

Policies are provided to jOOQ via the usual SPI configuration point, the Configuration. As with all jOOQ SPIs, this means that multiple Configurations are possible in parallel, depending on your database interaction use-case. For example:

  • A super user may be able to access all data
  • A staff user may be able to access only 1-2 tenants
  • A customer user may be able to access only their own customer data

In such a setup, you'll already have different database users with different privileges (see also security considerations), so you can attach one set of policies to each database user.

One way to create policies is by using the org.jooq.impl.DefaultPolicyProvider:

Configuration configuration = ...;
configuration.set(new DefaultPolicyProvider()

    // Append a Policy to the PolicyProvider

        // The table on which to apply a policy

        // The condition to apply to queries against the table

    // Append another Policy to the PolicyProvider
    .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(40183))

References to this page


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

The jOOQ Logo