JOOQ:将列标记为“已弃用”?

Sho*_*orn 5 jooq

我想以某种方式将模式中的列标记为“已弃用”(可能是列注释中的某种标记或其他内容),然后让该信息通过代码生成过程冒泡,以导致添加@Deprecated注释到生成的代码中该列的字段/方法。

JOOQ有相关的功能吗?
浏览用户手册似乎没有显示任何相关内容。

Luk*_*der 2

使用 jOOQ 3.15 综合评论功能

从jOOQ 3.15开始,您可以使用代码生成器的合成注释功能,例如

<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.16.0.xsd">
  <generator>
    <database>
      <comments>
        <comment>
        
          <!-- Regular expression matching all objects that have this comment. -->
          <expression>CONFIGURED_COMMENT_TABLE</expression>
          
          <!-- Whether the comment is a deprecation notice. -->
          <deprecated>true</deprecated>
          
          <!-- Whether the original schema comment should be included. -->
          <includeSchemaComment>false</includeSchemaComment>
          
          <!-- The actual comment text. Defaults to no message. -->
          <message>Do not use this table.</message>
        </comment>
      </comments>
    </database>
  </generator>
</configuration>
Run Code Online (Sandbox Code Playgroud)

使用 SQL 注释进行黑客攻击

使用此技巧(如果您的 RDBMS 支持注释):

COMMENT ON COLUMN my_table.my_column IS '@deprecated';
Run Code Online (Sandbox Code Playgroud)

它不会生成注释,但会生成等效的 Javadoc,这在 IDE 中具有相同的效果。