I am dynamically creating and using physical DB tables for which I only have one metamodel object. An example: I have one JOOQ class
Customer CUSTOMER1 = Customer.rename("CUSTOMER1")
The question being in the title:
why is there no Table.rename(String)?
The feature was implemented in jOOQ 3.3 (#2921). The issue reads:
As table renaming is not really a SQL DSL feature, the rename() method should be generated onto generated tables only, instead of being declared in org.jooq.Table
In fact, this argument doesn't really make much sense. There are other "non-DSL" utilities on the DSL types. I don't see why
rename() is special. The method should be declared on
Table as you suggested. This will be done in jOOQ 3.9 (#5242).
From the update of your question, I understand that you don't really need that fine-grained renaming control. jOOQ's out of the box multi-tenancy feature will do. This is called "table mapping" in the manual:
For the scope of a
Configuration (most fine-grained scope: per-query level), you can rewrite any matching table name as such:
Settings settings = new Settings() .withRenderMapping(new RenderMapping() .withSchemata( new MappedSchema().withInput("MY_SCHEMA") .withOutput("MY_SCHEMA") .withTables( new MappedTable().withInput("CUSTOMER") .withOutput("CUSTOMER1"))));