最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - Is there a way to have code generator generate a list of constants for all table names and columns? - Stack Overflow

programmeradmin7浏览0评论

I need to use table name/column names in annotations so they must be constant (can't call TABLE1.getName()).

Is there a way to have Jooq code generator generate these automatically in the format of public static final String TABLE1 = "table1"

and similarly for columns inside each table?

I need to use table name/column names in annotations so they must be constant (can't call TABLE1.getName()).

Is there a way to have Jooq code generator generate these automatically in the format of public static final String TABLE1 = "table1"

and similarly for columns inside each table?

Share Improve this question edited 6 hours ago jonrsharpe 122k30 gold badges267 silver badges474 bronze badges asked 7 hours ago MahdiMahdi 2,2933 gold badges28 silver badges49 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

In jOOQ 3.19+, you can enable globalObjectNames in the code generator: https://www.jooq./doc/latest/manual/code-generation/codegen-advanced/codegen-config-generate/codegen-generate-global-object-names/

Here's how to configure it with Maven

<configuration>
  <generator>
    <generate>
      <globalObjectNames>true</globalObjectNames>
    </generate>
  </generator>
</configuration>

Or Gradle:

configuration {
  generator {
    generate {
      isGlobalObjectNames = true
    }
  }
}
发布评论

评论列表(0)

  1. 暂无评论