可用版本:Dev (3.21) | 最新 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

匹配器示例

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

以下示例展示了一种 matcher 策略,该策略将 "T_" 前缀添加到所有表类和表标识符

XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
  <generator>
    <strategy>
      <matchers>
        <tables>
          <table>

            <!-- Expression is omitted. This will make this rule apply to all tables -->
            <tableIdentifier>
              <transform>UPPER</transform>
              <expression>T_$0</expression>
            </tableIdentifier>
            <tableClass>
              <transform>PASCAL</transform>
              <expression>T_$0</expression>
            </tableClass>
          </table>
        </tables>
      </matchers>
    </strategy>
  </generator>
</configuration>

有关更多详细信息,请参阅配置 XSD独立代码生成以及maven 代码生成

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withStrategy(new Strategy()
      .withMatchers(new Matchers()
        .withTables(
          new MatchersTableType()

            // Expression is omitted. This will make this rule apply to all tables
            .withTableIdentifier(new MatcherRule()
              .withTransform(MatcherTransformType.UPPER)
              .withExpression("T_$0")
            )
            .withTableClass(new MatcherRule()
              .withTransform(MatcherTransformType.PASCAL)
              .withExpression("T_$0")
            )
        )
      )
    )
  )

有关更多详细信息,请参阅配置 XSD程序化代码生成

import org.jooq.meta.jaxb.*


configuration {
  generator {
    strategy {
      matchers {
        tables {
          table {

            // Expression is omitted. This will make this rule apply to all tables
            tableIdentifier {
              transform = MatcherTransformType.UPPER
              expression = "T_$0"
            }
            tableClass {
              transform = MatcherTransformType.PASCAL
              expression = "T_$0"
            }
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

configuration {
  generator {
    strategy {
      matchers {
        tables {
          table {

            // Expression is omitted. This will make this rule apply to all tables
            tableIdentifier {
              transform = "UPPER"
              expression = "T_$0"
            }
            tableClass {
              transform = "PASCAL"
              expression = "T_$0"
            }
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式

以下示例展示了一种 matcher 策略,该策略将 BOOK 表标识符(或包含 BOOK 的表标识符)重命名为 BROCHURE(或包含 BROCHURE 的表)

XML(独立和 Maven)
编程方式
Gradle (Kotlin)
Gradle (Groovy)
Gradle(第三方)
<configuration>
  <generator>
    <strategy>
      <matchers>
        <tables>
          <table>
            <expression>^(.*?)_BOOK_(.*)$</expression>
            <tableIdentifier>
              <transform>UPPER</transform>
              <expression>$1_BROCHURE_$2</expression>
            </tableIdentifier>
          </table>
        </tables>
      </matchers>
    </strategy>
  </generator>
</configuration>

有关更多详细信息,请参阅配置 XSD独立代码生成以及maven 代码生成

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(new Generator()
    .withStrategy(new Strategy()
      .withMatchers(new Matchers()
        .withTables(
          new MatchersTableType()
            .withExpression("^(.*?)_BOOK_(.*)$")
            .withTableIdentifier(new MatcherRule()
              .withTransform(MatcherTransformType.UPPER)
              .withExpression("$1_BROCHURE_$2")
            )
        )
      )
    )
  )

有关更多详细信息,请参阅配置 XSD程序化代码生成

import org.jooq.meta.jaxb.*


configuration {
  generator {
    strategy {
      matchers {
        tables {
          table {
            expression = "^(.*?)_BOOK_(.*)$"
            tableIdentifier {
              transform = MatcherTransformType.UPPER
              expression = "$1_BROCHURE_$2"
            }
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

configuration {
  generator {
    strategy {
      matchers {
        tables {
          table {
            expression = "^(.*?)_BOOK_(.*)$"
            tableIdentifier {
              transform = "UPPER"
              expression = "$1_BROCHURE_$2"
            }
          }
        }
      }
    }
  }
}

有关更多详细信息,请参阅配置 XSDgradle 代码生成

// The jOOQ-codegen-gradle plugin has been introduced in version 3.19.
// Please use the official plugin instead of the third party plugin that was recommended before.

一如既往,当使用正则表达式时,它们是具有默认标志的正则表达式

有关每个 XML 标记的更多信息,请参阅 https://jooq.org.cn/xsd/jooq-codegen-3.20.1.xsd XSD 文件。

反馈

您对此页面有任何反馈吗? 我们很乐意倾听!

The jOOQ Logo