简体   繁体   English

JOOQ - 如何获取TableField的tbl_name.col_name?

[英]JOOQ - How to get the tbl_name.col_name of a TableField?

How to get the table + column qualifier name from the TableField . 如何从TableField获取表+列限定符名称。

I have tried the following methods 我尝试了以下方法

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

As you've noticed, the TableField.toString() method renders the fully qualified column. 正如您所注意到的, TableField.toString()方法呈现完全限定列。 You have two options: 您有两种选择:

Do it yourself: 自己做:

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

Use a Configuration that is configured to omit the schema name: 使用Configuration ,其配置省略架构名称:

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM