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

This is experimental functionality, and as such subject to change. Use at your own risk!

Table mapping Replacer

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

jOOQ has a powerful runtime catalog, schema, and table mapping feature, which can be used to implement multi tenancy use-cases, etc. This mapping functionality is meant as a global configuration for the entirety of your application. Very often, however, you need to map just a single table, or a small set of tables for a specific purpose, for example:

-- Input
SELECT t.id, t.value FROM t

-- Output
SELECT u.id, u.value FROM u

In order to achieve this, just apply the following replacement:

Select<?> input = select(T.ID, T.VALUE).from(T);
Select<?> output = (Select<?>) input.$replace(Replacers.mappingTable(T, U));

Or, if the decision what to map is more elaborate, use a lambda:

Select<?> input = select(T.ID, T.VALUE).from(T);
Select<?> output = (Select<?>) input.$replace(Replacers.mappingTable(t -> T.equals(t) ? U : t));

Feedback

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

The jOOQ Logo