This is experimental functionality, and as such subject to change. Use at your own risk!
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.
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!