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.
Configuration
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A org.jooq.Policy
is a configuration consisting of a:
-
Policy.table()
: The table that it applies to -
Policy.condition()
: The condition to apply to the query that uses the table -
Policy.inherited()
: Whether a policy on a parent table is inherited by child tables
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 .append( // The table on which to apply a policy TENANT, // The condition to apply to queries against the table TENANT.TENANT_ID.eq(42)) // Append another Policy to the PolicyProvider .append(CUSTOMER, CUSTOMER.CUSTOMER_ID.eq(40183)) );
Feedback
Do you have any feedback about this page? We'd love to hear it!