JOOQ Metamodel: why not Table.rename (String)?

I dynamically create and use physical database tables, for which I have only one metamodel object. Example: I have one JOOQ class Customerin my metamodel, but at runtime I have CUSTOMER1, CUSTOMER2etc. I would like to write strongly typed JOOQ queries for these dynamic tables. The following seems to do the trick:

Customer CUSTOMER1 = Customer.rename("CUSTOMER1")

Of course, there are a whole bunch of tables for which I need to do this. Unfortunately, I cannot use the method renamein the general case, because it is not part of the interface Table<R>. Is this oversight or a deliberate measure against something that I do not see?

Is there a sustainable and elegant way to achieve what I want, i.e. not resort to thought?

EDIT: Two tables are never shared in the same query. The specific usage pattern is this: at any moment the synonym DB Customerwill point to one (active), while the other changes (shadow copy). Once the modification is completed, the roles change places, pointing to a synonym for another, and we start over. We do this to minimize the “downtime” of large reporting results tables.

+4
source share
1 answer

The answer to your question

The question is in the title:

why not Table.rename (String)?

The function was implemented in jOOQ 3.3 ( # 2921 ). The problem is:

DSL SQL, rename() , org.jooq.Table

. " DSL" DSL. , rename() . Table, . jOOQ 3.9 (# 5242).

, . jOOQ - . " " :

http://www.jooq.org/doc/latest/manual/sql-building/dsl-context/runtime-schema-mapping

Configuration ( : ) :

Settings settings = new Settings()
    .withRenderMapping(new RenderMapping()
    .withSchemata(
        new MappedSchema().withInput("MY_SCHEMA")
                          .withOutput("MY_SCHEMA")
                          .withTables(
         new MappedTable().withInput("CUSTOMER")
                          .withOutput("CUSTOMER1"))));
+1

All Articles