JOOQ - How to get the block_name tbl_name.col_ of a table?

How to get table + column qualifier name from TableField .

I have tried the following methods

USER.ID.toString(); // "db.user.id"
USER.ID.getName();  // "id"

      

+3


source to share


1 answer


As you noticed, the method TableField.toString()

displays the full column. You have two options:

Do it yourself:

String sql = USER.getName() + "." + USER.ID.getName();

      



Use Configuration

which is configured for the missing schema name:

Settings settings = new Settings();
settings.setRenderSchema(false);                    // Omit schema rendering
settings.setRenderNameStyle(RenderNameStyle.AS_IS); // Omit escaping names
DSLContext = DSL.using(SQLDialect.MYSQL, settings);
String sql = ctx.render(USER.ID);

      

+4


source







All Articles